我有這個腳本..首先我運行查詢1並存儲到數組然後查詢2, 使用foreach,我將它們組合並創建一個urls列表..但這需要時間。 。有沒有一種方法可以在MySQL中通過組合表來完成,即使他們沒有共同的列?mysql加入兩個表沒有共同點
查詢1
SELECT
c.id,
c.city_name,
r.region_name,
cr.country_name
FROM city AS c, region AS r, country AS cr
WHERE r.id = c.id_region
AND cr.id = c.id_country
AND cr.id IN
(SELECT id FROM country WHERE used = 1)
查詢2
SELECT id, title FROM param WHERE active = 1
環
foreach ($arrayCity as $city) {
foreach ($arrayParam as $param) {
$paramTitle = str_replace(' ', '+', $param['title']);
$url = 'http://url/city/'. $city['id'] .'/paramId/'. $param['id'] .'/'.
$paramTitle .'/'. $city['region_name'] .'/'. $city['city_name'];
}
}
雞蛋裏挑骨頭,但' '遠不是交叉連接的同義詞。它僅僅是所有聯接的pre-SQL 1992語法的一部分(表列表定界符部分)。 –