写入存储过程方法 [英] write in storeprocedure method

查看:58
本文介绍了写入存储过程方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表.
1.city->其中包含ID,城市名称
2.city_course_details->其中包含id,city_id(是对城市表的引用.)



我如何使用存储过程方法编写代码,以便在选择城市名称时也可以从city_course_details获取信息


实际上,我想了解外键,如何通过storeprocedure方法使用..给出任何示例

i have two table.
1.city->which contain id,cityname
2.city_course_details->which contain id ,city_id(which is reference to city table.)



how i write in stored procedure method so that,when i select city name it will also take information from city_course_details


Actually i want to know about foreign key, how i used through storeprocedure method..give any example

推荐答案

阅读此内容,了解如何创建存储过程加入基础知识 [
Read this on how to create stored procedures Stored Procedures (Database Engine)[^] and this on how use a JOIN Join Fundamentals[^].

Good luck.


select cc.id,cc.city_id from city_course_details cc inner join city c
on cc.city_id=c.id
where c.cityname=''your city name''



据我了解您的问题,这就是您要寻找的.
如果这不是您想要的,请再次更清楚地问我.
您可以在存储过程中编写此查询.



as far as i understood your question this is what you are looking for.
if this is not what you want then once again ask me some more clearly.
you can write this query in stored procedure.


create proc Sel_City
@CityName nvarchar(50)
as
select CC.*, c.* from city_course_details cc inner join city c
on cc.city_id=c.id
where c.cityname=@CityName



您可以将CC.*和C. *更改为仅所需的列名.



You can change CC.* and C.* to only the required column name.


这篇关于写入存储过程方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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