
SQL联表查询问题
有2个表news_table有字段(nid,title,type_id)name_table有字段(type_id,type_name)意思就是news_table里的t...
有2个表
news_table 有字段(nid,title,type_id)
name_table 有字段(type_id,type_name)
意思就是news_table里的type没有直接给出名字,而是存了个name_table里的id
我想通过一句SQL或最简洁的,查找新闻的title和type_name,该这么写啊? 展开
news_table 有字段(nid,title,type_id)
name_table 有字段(type_id,type_name)
意思就是news_table里的type没有直接给出名字,而是存了个name_table里的id
我想通过一句SQL或最简洁的,查找新闻的title和type_name,该这么写啊? 展开
6个回答
展开全部
select a.title,b.type_name from news_table as a,name_table as b where a.type_id=b.type_id ; 如果后面还要对选择的新闻加上限制的话,where后面跟上 and a.nid=? 希望我的回答对你有所帮助!
展开全部
select news_table.title,name_tabl.type_name
from news_table,name_table
where news_table.type_id=name_table.type_id
--数据库查询: select 查询的列 from 表 where 条件 ,基本上简单的查询就是这种格式,select 以及from 必须要有,where条件可有可没有。
from news_table,name_table
where news_table.type_id=name_table.type_id
--数据库查询: select 查询的列 from 表 where 条件 ,基本上简单的查询就是这种格式,select 以及from 必须要有,where条件可有可没有。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.title,b.type_name
from news_table as a,name_table as b
where a.type_id=b.type_id ;
如果后面还要对选择的新闻加上限制的话,where后面跟上 and a.nid=?
希望我的回答对你有所帮助!
from news_table as a,name_table as b
where a.type_id=b.type_id ;
如果后面还要对选择的新闻加上限制的话,where后面跟上 and a.nid=?
希望我的回答对你有所帮助!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.title,b.type_name
from news_table a,name_table b
where a.type_id=b.type_id
from news_table a,name_table b
where a.type_id=b.type_id
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.title,b.type_name from news_table a,name_table b where
a.type_id=b.type_id
a.type_id=b.type_id
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询