如何从多个表中获取数据MySQL [英] how to fetch data from multiple tables MySQL

查看:79
本文介绍了如何从多个表中获取数据MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在php + MySQL + jquery中寻求帮助 我有2张桌子

I am looking some help in php+MySQL+jquery I have 2 tables

表1 表1有4种 (id,标题,desc,thumb_img)

table1 table 1 have 4 colume (id, title, desc, thumb_img)

tabel2 表2包含3种名称(id,table1id,img)

tabel2 table 2 have 3 colume(id, table1id, img)

我只想将2个表与$ _get ['QS']的值进行比较; 并同时显示两个记录(标题,说明,img)

I just want to compare 2 table with the value of $_get['QS']; and show the records from both (title, desc, img)

期待获得帮助.:)

推荐答案

SELECT t1.title, t1.desc, t2.img
FROM table1 AS t1
JOIN table2 AS t2
  ON t1.id=t2.table1id
WHERE somefieldyoudidntspecify=:qs

这篇关于如何从多个表中获取数据MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆