-2

我有两张桌子

用户

ID   Name  
1    test      
2    test2

应用

UserID    URL
  1       website1
  2       website2

我正在尝试执行一个查询,该查询将创建与此类似的内容。

查询结果

Name     URL
test     website1
test2    website2

我的尝试

SELECT u.Name, a.URL FROM users as u, application as a INNER JOIN u.ID = a.UserID

我试过这个,但它似乎没有工作。任何帮助,将不胜感激。

4

6 回答 6

2

需要注意的几项,表别名不需要asjoin推断出内部连接。此查询还取决于应用程序表的实际名称,您可能需要替换为artist_application.

SELECT u.Name, a.URL 
FROM users u 
join application a
on u.ID = a.UserID
于 2013-10-24T13:30:13.723 回答
1

尝试JOIN

Select
u.Name, 
a.URL
from 
`USERS` u
INNER JOIN artist_application a on (u.id = a.userId)
于 2013-10-24T13:30:05.537 回答
1

正确的语法是

SELECT u.Name, a.URL 
FROM users as u
left join artist_application as a on u.ID = a.UserID
于 2013-10-24T13:30:12.417 回答
0
SELECT u.Name, a.URL 
FROM users as u, artist_application as a 
WHERE u.ID = a.UserID
于 2013-10-24T13:33:00.293 回答
0

您可以执行以下操作:

SELECT u.Name, a.URL
FROM users as u, artist_application as a
WHERE u.ID = a.UserID
于 2013-10-24T13:34:51.020 回答
0

干得好。

SELECT u.Name, a.URL FROM users as u INNER JOIN artist_application as a on u.ID = a.UserID

于 2013-10-24T13:35:16.150 回答