I need a little help in putting a code in the below sql code.
我需要一点帮助,将代码放在下面的sql代码中。
My code is -
我的代码是 -
torrentlang.name AS lang_name, FROM torrentlang LEFT JOIN torrentlang ON torrentlang = torrentlang.id
I want to put it inside the below query:
我想把它放在下面的查询中:
$query = " SELECT
torrents.id,
torrents.category,
torrents.name,
torrents.image1,
torrents.added,
torrents.size,
torrents.hits,
torrents.banned,
torrents.comments,
torrents.seeders,
torrents.leechers,
torrents.times_completed,
categories.name AS cat_name,
categories.parent_cat AS cat_parent
FROM torrents
LEFT JOIN categories
ON category = categories.id
WHERE categories.parent_cat = 'Movies'
ORDER BY added DESC
LIMIT 2";
$query12 = mysql_query($query)or die(mysql_error());
Please help!
I need the result as below:
我需要如下结果:
$query = "SELECT
torrents.id,
torrents.category,
torrents.name,
torrents.image1,
torrents.added,
torrents.size,
torrents.hits,
torrents.banned,
torrents.comments,
torrents.seeders,
torrents.leechers,
torrents.times_completed,
categories.name AS cat_name,
categories.parent_cat AS cat_parent
FROM torrents
LEFT JOIN categories
ON category = categories.id,
torrentlang.name AS lang_name,
FROM torrentlang
LEFT JOIN torrentlang
ON torrentlang = torrentlang.id
WHERE categories.parent_cat = 'Movies'
AND torrentlang.id = '3'
ORDER BY added DESC
LIMIT 2";
$query12 = mysql_query($query)or die(mysql_error());
Please correct the above result code!
请更正以上结果代码!
1 个解决方案
#1
1
try this
SELECT torrents.id, torrents.category, torrents.name, torrents.image1, torrents.added, torrents.size, torrents.hits, torrents.banned, torrents.comments, torrents.seeders, torrents.leechers, torrents.times_completed, categories.name AS cat_name, categories.parent_cat AS cat_parent ,torrentlang.name AS lang_name
FROM torrents
LEFT JOIN categories ON torrents.id = categories.id
LEFT JOIN torrentlang ON torrents.id = torrentlang.id
WHERE categories.parent_cat = 'Movies'
AND torrentlang.id = 3
ORDER BY added DESC LIMIT 2
assuming that torrents.id = categories.id
and torrents.id = torrentlang.id
假设torrents.id = categories.id和torrents.id = torrentlang.id
#1
1
try this
SELECT torrents.id, torrents.category, torrents.name, torrents.image1, torrents.added, torrents.size, torrents.hits, torrents.banned, torrents.comments, torrents.seeders, torrents.leechers, torrents.times_completed, categories.name AS cat_name, categories.parent_cat AS cat_parent ,torrentlang.name AS lang_name
FROM torrents
LEFT JOIN categories ON torrents.id = categories.id
LEFT JOIN torrentlang ON torrents.id = torrentlang.id
WHERE categories.parent_cat = 'Movies'
AND torrentlang.id = 3
ORDER BY added DESC LIMIT 2
assuming that torrents.id = categories.id
and torrents.id = torrentlang.id
假设torrents.id = categories.id和torrents.id = torrentlang.id