Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi How can i re-write this so i

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi

How can i re-write this so it can suit my mySQL version:

select

pl_stockid,
(select stock_name from tblstocks where stock_id = pl_stockid) as stock_name,
(select stock_thumbnail from tblstocks where stock_id = pl_stockid) as stock_thumbnail

from tblpricelist
where pl_price2 <= 50
group by pl_stockid

Thanks

 
Using joins. Something like:

select
p.pl_stockid, s.stock_name, s.stock_thumbnail
from
tblpricelist p
join
tblstocks s
on p.pl_stockid = s.stockid
where
p.pl_price2 <= 50
group by
p.pl_stockid


See also the MySQL online manual entry for rewriting queries to remove subqueries:
Want the best answers? Ask the best questions: TANSTAAFL!!
 
It still doesn't work! it states:

[Administrator] ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'on p.pl_stockid = s.stockid

where
p.pl_price2 <= 50
group b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top