Log in

View Full Version : data base query



willssmith
01-23-2013, 07:10 AM
Hi all.

I have two tables: products and products_description. They have different number of columns. I want to select information from both tables with a single query. When I try the query below, I get a 1064 error. Can you help?

djr33
01-23-2013, 07:58 AM
What's the query?

willssmith
01-24-2013, 08:40 AM
My query is

Select from Product, products_description order by Product.ID

but getting error

traq
01-24-2013, 03:18 PM
You're not specifying which columns you want, for starters.
You also need to specify how to join the tables.
Read the MySQL docs on JOINs (http://dev.mysql.com/doc/refman/5.0/en/join.html) for more info.

For example
(not likely to work "as-is" -
e.g., this assumes that the records in Product have "matching" rows in product_description and that they share ID numbers -
plus, I don't know any of your column names aside from ID -
if you want a more specific answer, share your table schema):

SELECT `a`.`col1`,`b`.`col1`
FROM `Product` `a`
JOIN `products_description` `b`
ON `a`.`ID` = `b`.`ID`
ORDER BY `a`.`ID`

If you're looking for help, keep in mind that you need to provide as much information as possible.

If you have a problem with a database query, you need to share your query and table schema.
If you're getting an error, you need to share the error message.

jscheuer1
05-13-2013, 12:33 PM
This thread has been closed due to age. If anyone wants information on it, please start a new thread. Feel free to link back to this one if you feel it contains information important to your new thread.