i'm using mysql 5.5, here is a left join query with a literal list:
select tbl1.*, details.*
from ('a', 'b', 'c'... 300+ elements) as 'tbl1'
left join details
on
details.id=tbl1.id
but it doesn't work!
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a','b')' at line 1
how to make this list as a table??
Use UNION
select tbl1.*, details.*
from (select 'a'as id
union
select 'b' as id
union
select 'c' as id
union
...300) as tbl1
left join details
on
details.id=tbl1.id
See this Fiidle Logic
Instead of using Subquery, you can first create a table tbl1 as
create table tbl1
(
id varchar(1)
)
insert into tbl1
select 'a' as id
union
select 'b' as id
union
select 'c' as id
....300
now you can use table tbl1 for join
select tbl1.*, details.*
from 'tbl1'
left join details
on
details.id=tbl1.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With