MySql query


I have three simple DB tables and I'm trying to do a couple queries which should be simple but I seem to be getting stuck.

First I have 2 Tables with 3 columns in them.

TABLE1 with Col1, Col2 and Col3

TABLE2 with Col1, Col2 and Col3

I want to know if any data in TABLE1.Col1 matches TABLE2.Col1 and if so I want to produce a list.

Next TABLE1 and TABLE2 list qty of units. TABLE3 list other information such as descriptions. So I need to look at TABLE3.Col4 match it to either TABLE1.col1 or TABLE2.col1 and check TABLE1.Col2 and/or TABLE2.Col2 to determine if there is more than X available. If there is more than X available than I need to get all data from TABLE3 and the Col2 data from TABLE1 or TABLE2.



Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

probably you're looking for joins:

select a.*, b.*, c.*
from table1 a
join table2 b on a.col1 = b.col1
join table3 c on b.col2 = c.col4

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnAuthor Commented:

Sorry for the late response.

Thanks for the help!!!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.