Select Multiple Columns From Multiple Tables

后端 未结 3 851
萌比男神i
萌比男神i 2021-01-14 06:18

I\'m a beginner at MySQL and I\'m having a hard time trying to figure out how to solve this problem:

I have two tables with many entries each. Let\'s say these are t

3条回答
  •  广开言路
    2021-01-14 07:20

    Ben's answer solved my similar issue.

    SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
    FROM table1 t1, table2 t2
    WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456
    
    
    | asd | qax | 456 | 3 | 
    

    '3' being the data I require by querying the 'qax', 456 data in table2, otherwise you're specifying exactly what data will be returned from the columns.

    I only had 2 tables to query in my instance, so the AND expression I can get away with using, it probably isn't best practice and there's most likely a better way for matching data from multiple tables.

    EDIT: I've just realised this question is 5 years old.. I hope you achieved what you wanted to by now.

提交回复
热议问题