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!

I want to do a query like this, but

Status
Not open for further replies.

cocoadev

Programmer
Nov 11, 2003
4
GB
I want to do a query like this, but mysql doesn't want to know...

SELECT size.sizes FROM size, details WHERE details.productID = (SELECT details.productID FROM product, details WHERE product.combocode = 5 AND product.productID = details.productID) AND (size.sizeID = details.sizeID)

the child query returns two varchar(9) productID's  , because it return a table with two, would that be the problem?

If i remove the child query, and replace it with the fetched productID "QW118" it works fine.

Any help would be great, thanks, ben

MySQL said:
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 'SELECT details.productID
FROM product, details
WHERE product.co

 
Code:
WHERE details.productID IN (SELECT  details.productID     FROM  product, details  WHERE product.combocode = 5 AND product.productID = details.productID)

use IN instead of =

 
Ur tring a 'sub select' or 'nested query' , which is not supported by older versions of MySQL.

If u r using a server side language u can have multiple queries (in a loop) to have the outout u wanted.


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
in that case you can look at

thread436-695290 a workaround with older mysql versions

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top