2011-03-27 96 views
0

我是新来的sql/phpmyadmin和我有这个问题。问题与查询phpmyadmin

SELECT `2.checkNumber`,`1.customerName' 
FROM 
`classicmodels1` AS 1, 
`classicmodels2` AS 2 
WHERE `1.customerNumber`=`2.customerNumber` 
+1

您应该添加什么样的问题。虽然在这种情况下,我确信它是数字表别名。尝试't1'而不是'1' – 2011-03-27 08:39:53

+0

我仍然收到一个错误,说“#1046 - 没有选择数据库”。感谢您的帮助。 – user678502 2011-03-27 16:43:37

回答

2

替换:

`1.customerName' 

`1.customerName` 

甚至更​​好改写避免使用引号。此外,我会用“T1”和“T2”取代别名“1”和“2”:

SELECT t2.checkNumber,t1.customerName 
FROM 
classicmodels1 AS t1, 
classicmodels2 AS t2 
WHERE t1.customerNumber=t2.customerNumber 
+0

我仍然收到“#1046 - 没有选择数据库”的错误。感谢您的帮助。 – user678502 2011-03-27 16:38:39

+0

@user您需要在phpMyAdmin中选择一个数据库,然后才能运行该查询。应该有一个列表在左边 – 2011-03-27 16:46:52

+0

嗨,我现在得到这个错误#1146 - 表'classicmodels2.classicmodels1'不存在与此查询SELECT't2.payments.checkNumber','t1.customers.customerName ' FROM 'classicmodels1' AS t1, 'classicmodels2' AS t2 WHERE't1.customers.customerName' ='t2.payments.checkNumber' – user678502 2011-03-28 00:40:37