use label in SQL query

5 posts by 3 authors in: Forums > CMS Builder
Last Post: July 8, 2013   (RSS)

By Toledoh - July 7, 2013

Hi Guys,

I'm currently using the following to show a drop-list;

SELECT num, CONCAT(title, ' $', price,' each') product
FROM `<?php echo $TABLE_PREFIX ?>products`

and I also want to show the "location" field... ie.

SELECT num, CONCAT(title, location, ' $', price,' each') product
FROM `<?php echo $TABLE_PREFIX ?>products`

however, the location field is a list which uses the num as the value, to I need to show it's label, but I can't use

SELECT num, CONCAT(title, location:label, ' $', price,' each') product
FROM `<?php echo $TABLE_PREFIX ?>products`

Any thoughts?

Cheers,

Tim (toledoh.com.au)

By gregThomas - July 8, 2013

Hi Tim,

A slight modification on Larry's suggestion would be to add the select statement that retrieves the location directly to the CONCAT statement. You could do something similar to what I suggested in this post:

http://www.interactivetools.com/forum/forum-posts.php?postNum=2231099#post2231099

Let me know if you have any questions.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - July 8, 2013

Thanks Guys - I'll try to get my head around that!

Cheers,

Tim (toledoh.com.au)

By jenolan - July 8, 2013

ug subselects .. ;-) gotta be careful with them if I remember my mySQL performance hints.

---



Peace and Long Life