Forum Moderators: coopster

Message Too Old, No Replies

selecting from multiple rows

         

adammc

6:05 am on Jun 28, 2006 (gmt 0)

10+ Year Member



Hi Guys,

Can anyone possibly help me out here?

I am trying to achive the following but cant work out the correct format:

[php]
$SQL = " SELECT 'productCode' FROM sizes WHERE size6<1 OR size7<1 OR size8<1 OR size9<1 OR size10<1 OR size11<1 ";
[/php]

size6 though to size11 are all rows in the sizes table ;)

fkroerank

9:02 am on Jun 28, 2006 (gmt 0)

10+ Year Member



$SQL = mysql_query("SELECT 'productCode' FROM sizes WHERE size6 < 1 OR size7 < 1 OR size8 < 1 OR size9 < 1 OR size10 < 1 OR size11 < 1") or die(mysql_error());

your post actually looked right, so I put it into the query above. you may want to see if anything was found by using mysql_num_rows() If the query is wrong somehow it'll stop running the page and give you an error. If you get an error and cant figure it out post it here and maybe someone will be able to help ya out then.

Scally_Ally

10:58 am on Jun 28, 2006 (gmt 0)

10+ Year Member



do you mean rows or columns? if size6 to size11 are all columns then the query would work (i think) with a few extra apostrophes. like

$SQL = " SELECT 'productCode' FROM sizes WHERE size6<'1' OR size7<'1' OR size8<'1' OR size9<'1' OR size10<'1' OR size11<'1' ";

jatar_k

4:53 pm on Jun 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you actually don't need apostrophes around integers

what actually happens when you run that query adammc? and what happens if you run it with 'or die' as fkroerank showed?