有树表:
电子邮件块
blocks_id blocks_pos url_type blocks_folder
1 1 1 emails_block
2 2 1 emails_show
3 3 1 emails_add
4 4 0 emails_share
Emails_blocks_text
texts_id blocks_id langs_code
2 1 ru
1 1 ua
3 2 ua
Emails_blocks_aliases
blocks_id aliases_name
1 news
2 drafts
并有查询:
SELECT `blocks_id`, `blocks_folder`, `blocks_name`, `aliases_name`, `langs_code`
FROM `a_emails_blocks`
LEFT JOIN `a_emails_blocks_text` USING(`blocks_id`)
LEFT JOIN `a_emails_blocks_aliases` USING(`blocks_id`)
GROUP BY `blocks_id`
ORDER BY FIELD(`a_emails_blocks_text`.`langs_code`, 'ua', 'ru')
但是在结果上我有 blocks_id = 1而不是 langs_code 'ua',我有 langs 代码'ru'。 我不明白为什么不从另一张桌子订购。
blocks_id blocks_folder aliases_name langs_code
1 emails_block news ru
2 emails_show drafts ua
3 emails_add
4 emails_share