0

I am new to sql/phpmyadmin and am having problems with this query.

SELECT `2.checkNumber`,`1.customerName'
FROM 
`classicmodels1` AS 1,
`classicmodels2` AS 2
WHERE `1.customerNumber`=`2.customerNumber`
2
  • 1
    You should add what kind of problems. Although in this case, I'm fairly sure it's the numeric table aliases. Try t1 instead of 1 Commented Mar 27, 2011 at 8:39
  • I am still getting an error which says "#1046 - No database selected". Thank you for your help. Commented Mar 27, 2011 at 16:43

1 Answer 1

2

Replace:

`1.customerName'

with

`1.customerName`

Or even better rewrite it to avoid using quotes. Also I would replace aliases '1' and '2' with 't1' and 't2' respectively:

SELECT t2.checkNumber,t1.customerName
FROM 
classicmodels1 AS t1,
classicmodels2 AS t2
WHERE t1.customerNumber=t2.customerNumber
Sign up to request clarification or add additional context in comments.

4 Comments

I am still getting an error which says "#1046 - No database selected". Thank you for your help.
@user you need to choose a database in phpMyAdmin before you can run the query. There should be a list on the left hand side
Hi, I am now getting this error #1146 - Table 'classicmodels2.classicmodels1' doesn't exist with this query SELECT t2.payments.checkNumber,t1.customers.customerName FROM classicmodels1 AS t1, classicmodels2 AS t2 WHERE t1.customers.customerName=t2.payments.checkNumber
@user, you should read something about SQL. t2.payments.checkNumber - this is invalid construction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.