Mysql query statement

A   
a_id    a_title   a_key   a_desc   a_pid
1        A     A   A     1


B   
b_id    b_title   b_key   b_desc   b_pid
1        b                      2

C   
c_id    c_title   c_key   c_desc    c_pid
1                       



   
$title= Ctitile  || Btitile || Atitile

C,B,BA


Mar.04,2021

union . As for determining which table title is empty, leave it to programming language to do


SELECT IFNULL(c.c_title, IFNULL(b.b_title, a.a_title)) FROM c 
LEFT JOIN b ON b.b_id = c.c_id
LEFT JOIN a ON a.a_id = c.c_id
LIMIT 1
.
Menu