Jump to content

Recommended Posts

Thanks, another quick question - how would I ORDER BY the price value?

 

I have tried the following at the end of the query:

 

ORDER BY wp_postmeta

ORDER BY p3.meta_key

ORDER BY p4.meta_value

 

Neither seem to work

 

Here is my ammened query:

 

SELECT p.*
		FROM wp_posts AS p
		INNER JOIN wp_postmeta AS p1
		ON (p.ID = p1.post_id)
		CROSS JOIN
		wp_postmeta AS p2
		USING (post_id)
		CROSS JOIN
		wp_postmeta AS p3
		USING (post_id)
		WHERE
		p1.meta_key='state_value' AND p1.meta_value='Suffolk'
		AND
		p2.meta_key='beds_value' AND p2.meta_value='2'
		AND
		p3.meta_key='price_value' AND convert(p3.meta_value, signed) >= '100000'

 

I'd have thought it would be...

 

ORDER BY p2.meta_value

 

But I can't really remember what the output of the Search looked like :S if you provide an example set of data you wish to order I should be able to give better advice. :)

I'd have thought it would be...

 

ORDER BY p2.meta_value

 

But I can't really remember what the output of the Search looked like :S if you provide an example set of data you wish to order I should be able to give better advice. :)

 

I swear I tried that and it didn't work, but just tried again and it did! So thanks!

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.