Jump to content

sorting mysql_query with multiple OR arguments


swimmerphil1

Recommended Posts

Hi all. thanks in advance. Here is the issue ive run into.

 

I perform a mysql_query with multiple OR arguments

 

i.e. "SELECT * FROM `someTableName`

WHERE `zipCode` LIKE 'zipCode1'

OR  `zipCode` LIKE 'zipCode2'

OR ....; 

 

Is there any way to perform the mysql_query such that the returned rows can be outputted in the same order in which i listed the parameter zipCodeX, where  X = 1,2,3....

 

i.e. if i have 3 rows that are returned from the query:

row 1 has zipCode = zipCode2

row 2 has zipCode = zipCode3

row 3 has zipCode = zipCode1

then how can i easily sort/maniuplate the data so that I can output the information from each respective row in the following order:

row 3 data....

row 1 data ...

row 2 data....

 

 

Thanks again!

Regards,

Phil

 

 

Is there any way to perform the mysql_query such that the returned rows can be outputted in the same order in which i listed the parameter zipCodeX, where  X = 1,2,3....

 

No, but ...

 

ORDER BY zipCode

 

at the end of your query should give you the ordering you want.  But this is nothing to do with the order you listed the parameters in the query.  It's to do with the values in the zipCode column.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.