Jump to content

[SOLVED] Advanced SQL help


stevebluck

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 swear I tried that and it didn't work, but just tried again and it did! So thanks!

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.