1
votes

in this case there are 2 tables which is products and images table. what i want to do is select all the product from product table where condition(a column of product table) is "used" and inner join images using product-name(colomn of products and images table -foreign key)

i have tried using selct all, inner joint and where clause.

( "SELECT * FROM products p " where condition="used"

  • "INNER JOIN images i "
  • "USING ( product-name ) "

)

1
What is that??? What's with the bracket, double quote, the black thing before INNER JOIN and USING. How do you expect it to work? Have you even check MySQL documentation how to create a query?Eric
Well said @Eric. Also product-name is product minus name. Welcome to SO @s.am.i. Precise questions get much better responses, don't be put off, keep asking but improve the clarity.danblack
Sorry for the mistakes...brackets are because of i am using it inside if statement..and that black thing was + i typed it as + but it appeared as black things.am.i

1 Answers

2
votes

When you get a syntax error, consult the manual on SELECT. WHERE clauses come after JOIN like:

SELECT * FROM products p
INNER JOIN images i USING ( `product-name` )
WHERE condition="used"