[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


MySql query

Posted on 2011-10-06
Medium Priority
Last Modified: 2012-05-12

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.



Question by:jpldpd
LVL 41

Accepted Solution

ralmada earned 2000 total points
ID: 36925900
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

Author Comment

ID: 36958119

Sorry for the late response.

Thanks for the help!!!


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question