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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.