php - 将基于 table_1 列值的两个表连接到匹配的 table_2 列名?
问题描述
是否可以根据表 1 列值等于 table_2 列名将 2 个表连接在一起?
table_1 table_2
----- -------------
| A | | 1 | 2 | 3 |
|---| |-----------|
| 1 | | Q | W | E |
----- -------------
期望的结果是:
Select A from table_1 join table_2 WHERE table_1 A = table_2 column name.
Result:
1Q
我正在使用 PHP,对于可怜的 psudo SQL 感到抱歉,老实说,我不知道如何措辞。感谢您提供的任何帮助!
解决方案
SELECT CONCAT(table_1.A,"",table_2.1) as RESULT
FROM table_1
LEFT JOIN table_2 ON table_1.A = table_2.1
推荐阅读
- c# - 无法使用 c# 将表单显示为 mdiChild 表单
- nginx - 如何从 nginx 中的文件映射/重写多个源和目标 URL?
- php - 如何在会话中保留 $_GET 变量值
- python - 安装 Plotly 错误:命令错误,退出状态为 1:
- python - 给定一个字符串 S,使用 python 递归地从中删除连续的重复项
- excel - 使用 vba 创建动态单元格地址
- speech-recognition - 如何使用 sclite 测量 Librispeech 的 WER?
- php - 如何使用 PHP 为 2^63-1 (signed int) 列准备 2^64 (unsigned bigint)?
- sql - Postgres to_timestamp 函数
- hyperlink - glmnet:使用 lasso 或 ridge 拟合 GLMM 并添加二项式 cloglog 链接