SQL Question (1 Viewer)

chewy

SuperNintendo Chalmers
Local time
Today, 06:53
Joined
Mar 8, 2002
Messages
581
What is the difference between

SELECT * FROM Persons WHERE LastName = 'Majewski';

and

SELECT * FROM Persons WHERE LastName = "Majewski";

When will you run into trouble switching the single and double quotes? Or will I not run into trouble
 

Mile-O

Back once again...
Local time
Today, 06:53
Joined
Dec 10, 2002
Messages
11,316
chewy said:
When will you run into trouble switching the single and double quotes?

When the name might be O'Donnelly etc.

Then you'd have:

SELECT * FROM Persons WHERE LastName = 'O'Donnelly';

The 'O' would be a string in its own right - the Donnelly' part would cause an error.
 

chewy

SuperNintendo Chalmers
Local time
Today, 06:53
Joined
Mar 8, 2002
Messages
581
So should that be all wrapped in " " ?
 

Mile-O

Back once again...
Local time
Today, 06:53
Joined
Dec 10, 2002
Messages
11,316
The latter SQL statement you posted is the better one.
 

chewy

SuperNintendo Chalmers
Local time
Today, 06:53
Joined
Mar 8, 2002
Messages
581
cool Thanks for the Info!
 

Users who are viewing this thread

Top Bottom