JChilds Posted September 1, 2009 Share Posted September 1, 2009 I have two tables. 'Items' and 'sales' Items contains : Barcode, Code, Description, Qty, CPrice, Price, Department, Supplier Sales contains: Timestamp, Trans_ID, barcode, Qty_Sold, Price Originally I was going to store description etc in the sales table aswell as the items, but this seems silly. What I want to do is essentially this: Select * FROM Items,Sales WHERE Sales.Trans_ID = '27' AND Items.barcode = Sales.barcode And then use that data. Is this possible? So I could output it as: Sales.Timestamp, Sales.Barcode, Items.Description, Sales.Qty_Sold, Sales.Price Quote Link to comment https://forums.phpfreaks.com/topic/172638-select-from-table1-table2-where-table1field1-table2field2-possible/ Share on other sites More sharing options...
corbin Posted September 1, 2009 Share Posted September 1, 2009 Yes, it is possible. But a better way to do it is a JOIN. I suggest reading about the syntax of JOIN, and then reading about the difference between JOIN, RIGHT JOIN, and LEFT JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/172638-select-from-table1-table2-where-table1field1-table2field2-possible/#findComment-910042 Share on other sites More sharing options...
fenway Posted September 7, 2009 Share Posted September 7, 2009 What I want to do is essentially this: Select * FROM Items,Sales WHERE Sales.Trans_ID = '27' AND Items.barcode = Sales.barcode This is basically a join. Quote Link to comment https://forums.phpfreaks.com/topic/172638-select-from-table1-table2-where-table1field1-table2field2-possible/#findComment-914141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.