使用SQL查询数据库表

发布于 2025-01-25 15:57:49 字数 462 浏览 1 评论 0原文

目前在Java的Android Studio中进行项目,我正在尝试查询SQL的两个桌子。 表如下:

预订表

​/I.SSTATIC.NET/7HXYD.PNG“ alt =” user_bookings table>

用户表仅用于参考

noreferrer”>

例如,对于具有ID 2的用户,我想从预订表中出发时间&出发日期(12:30& 12/5/20222)和从User_bookings表中我想要人数(2)。

还是联盟/内部加入不是我要实现的目标的正确操作员?由于我一直在尝试和刷新我的SQL技能,但我似乎无法领先。

任何帮助都赞赏。

Currently doing a project in android studio in java and I'm trying to query two tables in sql.
The tables are as follows:

Bookings table

Bookings table

User_Bookings table

User_Bookings table

User table just for reference

enter image description here

Is there a way do to a UNION or INNER JOIN and connect these two tables with just the userID ?

Say for example for the user with ID 2 I want from the Bookings table the departure time & departure date (12:30 & 12/5/20222) and from the User_Bookings table I want the number of people (2).

Or is UNION/INNER JOIN not the right operators for what I am trying to achieve ? As I have been trying and brushing up on my SQL skills but I can't seem to get ahead of it.

Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角迷惘 2025-02-01 15:57:49
SELECT * FROM Bookings b INNER JOIN User_Bookings ub ON b.bookingID=ub.bookingID where ub.userID = <pass_parameter_actual_userID>
SELECT * FROM Bookings b INNER JOIN User_Bookings ub ON b.bookingID=ub.bookingID where ub.userID = <pass_parameter_actual_userID>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文