php - Merging 2 mysql table at specified positions -
i have 2 mysql tables listed below,
//first table (db_event)
id || name || publish 1 1 2 b 1 3 c 1 4 d 1 5 e 1 6 f 1
//second table (db_ads)
id || images || publish 1 a.jpg 1 2 b.jpg 1
i want merge second table db_ads
first table db_event
@ specified position ie, @ 5th position respectively.
my required result should below table,
//resulting table
id || name || images || publish 1 {null} 1 2 b {null} 1 3 c {null} 1 4 d {null} 1 5 e {null} 1 1 {null} a.jpg 1 6 f {null} 1 2 {null} b.jpg 1
is there method achieve result in php or mysql. don't need results in json.
if use,
while($event_rows = mysql_fetch_array($event)) { $name = $event_rows["name"]; $image= $event_rows["images"]; } echo $name; echo $image;
the result should appear.
i not find solution, if result depends on id values, may use -
select id, name, null images, publish db_event id < 6 union select id, null name, images, publish db_ads id = 1 ...
Comments
Post a Comment