我正在幫助他的網站的朋友,但我實際上堅持在這一點上。
他的數據庫是由他自己創建的,他沒有數據庫建模的知識,所以我很難從中獲得結果。
我有以下查詢至極有我需要的一切:這將產生以下結果
SELECT * FROM tabelaseriesbs
LEFT JOIN tabelatextosbs ON tabelatextosbs.nome = tabelaseriesbs.nome and tabelaseriesbs.alter_ego = tabelatextosbs.alter_ego and tabelatextosbs.versao = tabelaseriesbs.versao
LEFT JOIN tabelaformatosbs ON tabelaformatosbs.colecao = tabelaseriesbs.colecao,
(SELECT distinct tabelaseriesbs.nome, tabelaseriesbs.alter_ego, tabelaseriesbs.versao FROM tabelaseriesbs
LEFT JOIN tabelaformatosbs ON tabelaformatosbs.colecao = tabelaseriesbs.colecao,
(SELECT tabelaseriesbs.nome, tabelaseriesbs.alter_ego, tabelaseriesbs.versao FROM tabelaseriesbs
WHERE 1=1 AND (tabelaseriesbs.colecao = 'Universo Marvel') AND (tabelaseriesbs.raridade = 'Comum')
) col
WHERE 1=1 AND (col.nome = tabelaseriesbs.nome) AND (col.alter_ego = tabelaseriesbs.alter_ego)
AND (col.versao = tabelaseriesbs.versao) AND (tabelaformatosbs.formato >= 2)
) form
WHERE 1=1 AND (tabelaseriesbs.alter_ego = form.alter_ego)
AND (tabelaseriesbs.nome = form.nome)
AND (tabelaseriesbs.versao = form.versao)
AND (tabelatextosbs.sitiada_afiliacoes = '0')
ORDER BY tabelatextosbs.nome ASC, tabelatextosbs.alter_ego ASC, tabelatextosbs.versao ASC, cast(tabelaseriesbs.indice AS SIGNED) ASC;
indice nome series
2 Hawkeye Universo Marvel
4 Hawkeye Poderes Ocultos
6 Hawkeye Iniciativa Vingadores
8 Hawkeye Battle Box
10 Hawkeye Guerra Civil
1 Mercenary Universo Marvel
3 Mercenary Ascensão e Queda
5 Mercenary Ascensão e Queda - Deck
但由於第一傭兵的ID比ID下層這些線路應該出現在Hawkeye之前,如下所示:
indice nome series
1 Mercenary Universo Marvel
3 Mercenary Ascensão e Queda
5 Mercenary Ascensão e Queda - Deck
2 Hawkeye Universo Marvel
4 Hawkeye Poderes Ocultos
6 Hawkeye Iniciativa Vingadores
8 Hawkeye Battle Box
10 Hawkeye Guerra Civil
有沒有辦法做到這一點?或者在獲得結果後,我是否必須在代碼中執行此操作?此外,還有更多的領域比3,如果你需要完整的列表,請讓我知道。
哇,它工作完美。我已經嘗試過之前的團隊,但無法使用它,但使用內部連接是完美的。非常感謝你! –