Select From all tables - MySQL

前端 未结 6 421
灰色年华
灰色年华 2020-12-10 10:54

I have a mySQL database called listDB that contain several tables with column name Product etc. I want to SELECT from all tables where

6条回答
  •  既然无缘
    2020-12-10 11:59

    SELECT product FROM Your_table_name WHERE Product LIKE '%XYZ%';
    

    The above statement will show result from a single table. If you want to add more tables then simply use the UNION statement.

    SELECT product FROM Table_name_1 
    WHERE Product LIKE '%XYZ%'  
    UNION  
    SELECT product FROM Table_name_2 
    WHERE Product LIKE '%XYZ%'  
    UNION  
    SELECT product FROM Table_name_3 
    WHERE Product LIKE '%XYZ%' 
    

    ... and so on

提交回复
热议问题