-1
當列具有某些結構時,我如何從更多表中選擇查詢。所以我想用選擇ID,波薩等,從旅遊和istorie表變量從更多表中選擇具有相同結構的查詢
$sql = "SELECT id, titlu, link, poza, alt, keywords FROM istorie WHERE approved='1' LIKE '%''".$keyword."''%'='%''".$keyword."''%' ORDER BY RAND() LIMIT 3" ;
$query = mysqli_query($con, $sql);
if(!$query){
printf("Error: %s\n", mysqli_error($con));
exit();}
$istorielist = '';
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$id = $row["id"];
$titlu = $row["titlu"];
$link = $row["link"];
$poza = $row["poza"];
$alt = $row["alt"];
$istorielist .= '<div id="articol-content-more"><a href="/istorie/'.$link.'"><img src="/images/'.$poza.'.jpg"class="articol-content-more-image" alt="'.$alt.'"><p class="articol-content-more-title">'.$titlu.'</p></a><span><a class="articol-content-more-afla" href="/istorie/'.$link.'">Citește mai multe</a></span><span class="articol-content-more-fl"><div class="fb-share-button" data-layout="button_count" data-href="http://esticurios.ro/istorie/'.$link.'"></div></span></div>';
}
mysqli_free_result($query);
我想還集成了來自工作臺行程查詢,不僅從表istorie ,兩者具有某種結構ID,titlu,鏈接,波薩,ALT,關鍵詞
在你的查詢中使用union all。從t1選擇ID union從t2選擇ID –
你能給我一個例如的PHP代碼?我不知道 –
在這裏你有一些例子https://www.techonthenet.com/mysql/union_all.php –