Forum Moderators: coopster

Message Too Old, No Replies

Loop text in WHERE mysql

mysql where loop

         

twistedmind000

9:25 am on Oct 25, 2005 (gmt 0)



Hi i want to know if i can loop this text with variable in mysql query behind WHERE: order_id!= '$o_id'. this $o_id gets picked out of the database if its an other country then asked for. (example if logged in admin country = USA the NLD will not be shown)

I only want to know how to loop the text thats all help me :)

twistedmind000

9:38 am on Oct 25, 2005 (gmt 0)



Another possibillity would be making a loop from a database with the same text an variable exmpl $filter
that filter would contain order_id!= '100' order_id!= '102' etc.

zCat

10:58 am on Oct 25, 2005 (gmt 0)

10+ Year Member



You can do something like:

WHERE order_id NOT IN (101,102,103)

if you have a few values you want to exclude.

twistedmind000

11:18 am on Oct 25, 2005 (gmt 0)



i think my first post wasnt that clear... becous i know how to do that but i want to read them from the database so its not static

twistedmind000

11:48 am on Oct 25, 2005 (gmt 0)



Anyone have any help on this?

twistedmind000

12:22 pm on Oct 25, 2005 (gmt 0)



please?

Twisted Mind

1:35 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



I have the same problem :)

zCat

2:07 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



I'm still not exactly sure what you're after, but it sounds like you might need a subquery, e.g.

... WHERE order_id NOT IN (SELECT order_id FROM orders WHERE country='USA')

Although this will only work on MySQL 4.1 and later, IIRC.

Twisted Mind

2:24 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



hmm its not what im asking for but it might be working and it certain something that does exist :P ill try it out have mysql latest dont worry

Twisted Mind

2:27 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE order_id NOT IN (SELECT order_id FROM mos_pshop_orders WHERE country='NLD'' at line 7
well i thought it should work but it says this what now? (changed some to variables)

Twisted Mind

2:32 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



forgot some things had 2ce where on start and forgot )
now it says: Unknown column 'country' in 'where clause'

Twisted Mind

2:35 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



did some things wrong myself now it works completely the oppisite it shows the ones it should not show but this will be an easy edit thanks dude u are the best

Twisted Mind

8:46 am on Oct 26, 2005 (gmt 0)

10+ Year Member



Works like a train forgot to say that