Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
Thread: DISTINCT question
05-17-2014, 06:24 PM #1
Which of these is correct...
$q1 = "SELECT DISTINCT (article)
$q1 = "SELECT DISTINCT article
It doesn't matter...
05-17-2014, 07:26 PM #2
- Join Date
- May 2005
- Southern tip of Silicon Valley
- Thanked 233 Times in 226 Posts
Did you run a test to see if there was any difference between #1 and #2?
Did you receive any errors? If not, then both are "correct".
I have never seen any examples that used the parens and I have never used them, but I just ran a test and got the same results, so the answer is #3;
05-18-2014, 02:11 AM #3
Just wanted to make sure I wasn't writing code that might blow up!!
05-26-2014, 03:52 PM #4
- Join Date
- Mar 2006
- St. Catharines, Ontario Canada
- Thanked 155 Times in 146 Posts
Don't use the brackets because when you select more than one column and are in the habit of using the brackets you may incorrectly think they should be there
SELECT DISTINCT (columnA), columnB, columnC FROM sometable
Users who have thanked guelphdad for this post:
05-26-2014, 06:15 PM #5