存储过程的sql查询
我有五个表“ArtBook、Eng、comm、Law、mgt”,每个表都有相同的列,我想通过其 id 搜索该特定书籍的所有信息 例如-
select * from ArtBook,Eng,Comm,Law,mgt where @BookId=ArtBooks.BookId
or @BookId=CommBooks.BookId
or @BookId=Eng.BookId
or @BookId=Law.BookId
or @BookId=mgt.BookId
I have five tables "ArtBook,Eng,comm,Law,mgt" and every table has a same column and i want to be search all the information that particular book by its id
e.g-
select * from ArtBook,Eng,Comm,Law,mgt where @BookId=ArtBooks.BookId
or @BookId=CommBooks.BookId
or @BookId=Eng.BookId
or @BookId=Law.BookId
or @BookId=mgt.BookId
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果所有表都存储不同类别的书籍,则将它们合并回一个表并添加“类别”列。出于您所演示的原因,像这样分类到单独的表中并不是一个好主意。
If all the tables store books of different categories, then combine them back into one table and add a 'category' column. Categorising into separate tables like this isn't a good idea for the reasons you've demonstrated.
可以使用 UNION 或 UNION ALL 运算符。
等等,等等。尽管您可能会考虑重组数据的存储方式以使此类事情变得更容易。
One could use the UNION or UNION ALL operator.
et cetera, et cetera. Though you may consider restructuring how your data is stored to make this sort of thing easier.