I have a table named alumnidetails with columns(username,firstname,mobile,email) and another table alumwork with columns(username,work,course,branch). Now i want to select data from both tables. I have only firstname value. What is the sql query. Please help me out.
我有一个名为alumnidetails的表,其中包含列(用户名,名字,移动设备,电子邮件)和另一个包含列(用户名,工作,课程,分支)的表。现在我想从两个表中选择数据。我只有名字值。什么是SQL查询。请帮帮我。
1 个解决方案
#1
0
SELECT
*
FROM
alumnidetails ad
INNER JOIN alumwork aw
ON ad.username = aw.username
WHERE
ad.firstname = ‘Pete’;
By the way, it's uncommon to connect two tables using strings (username, in your case). It's way slower than using id's. You could add an 'id' column your alumnidetails table, and a 'alumnidetails_id' column in your alumwork table.
顺便说一句,使用字符串连接两个表(在您的情况下是用户名)并不常见。它比使用id慢。您可以在alumnidetails表中添加“id”列,并在alumwork表中添加“alumnidetails_id”列。
Your naming is inconsistent too, by the way. And that's gonna annoy someone at some point.
顺便说一下,你的命名也是不一致的。那会在某个时候惹恼某人。
#1
0
SELECT
*
FROM
alumnidetails ad
INNER JOIN alumwork aw
ON ad.username = aw.username
WHERE
ad.firstname = ‘Pete’;
By the way, it's uncommon to connect two tables using strings (username, in your case). It's way slower than using id's. You could add an 'id' column your alumnidetails table, and a 'alumnidetails_id' column in your alumwork table.
顺便说一句,使用字符串连接两个表(在您的情况下是用户名)并不常见。它比使用id慢。您可以在alumnidetails表中添加“id”列,并在alumwork表中添加“alumnidetails_id”列。
Your naming is inconsistent too, by the way. And that's gonna annoy someone at some point.
顺便说一下,你的命名也是不一致的。那会在某个时候惹恼某人。