gpt4 book ai didi

sqlite - SQLite从其他表中获取值(value)

转载 作者:行者123 更新时间:2023-12-03 15:08:30 26 4
gpt4 key购买 nike

假设我有一个table1abbr_state, thing1, thing2

table2与:state, code (the index), thing3

所以abbr_state = GA,而state = Georgiacode = GA

无论如何,我可以在哪里做一个SELECT

SELECT abbr_state,thing1,thing2 FROM table1 ORDERY BY blah blah blah...

但是要确保它执行abbr_state时,它来自完整的州名而不是缩写吗?

最佳答案

可以使用的查询是:

SELECT abbr_state, state, thing1, thing2 
FROM table1 INNER JOIN table2
ON table1.abbr_state = table2.code
ORDER BY blah;


如果需要,可以在 WHERE子句之前添加任何 ORDER BY条件。或者,甚至可以将它们合并在 JOIN语句中:

      ....
ON table1.abbr_state = table2.code
AND table1.fielda = 'xyz'
....

关于sqlite - SQLite从其他表中获取值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42034758/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com