View Full Version : LEFT() returns nothing
maxpouliot
10-24-2006, 01:21 AM
How comes this always return nothing even though i have data in the name field
SELECT Left(joueurs.name,1) AS newName
FROM joueurs
Shoot2Kill
10-24-2006, 02:47 AM
Shouldn't it be....
SELECT LEFT(name, 1) AS newName
FROM joueurs.name
or
SELECT LEFT(name, 1) AS newName
FROM joueurs
not 100% sure which one, but give em a try...
maxpouliot
10-24-2006, 02:52 AM
Nope, this doenst work
Shoot2Kill
10-24-2006, 03:04 AM
SELECT LEFT(name, 1) AS newName FROM joueurs WHERE x= xxx
????
if that doesnt work, then sorry, i dunno.. :(
obviously, change x and xxx to the field you are looking for...
miller
10-24-2006, 03:59 AM
The SQL that you specified should work if you have data. Maybe it's simply returning a space, " ", and that's why you can't see it. Maybe there is some wierd thing dealing with the database you are using. Maybe you just aren't returning any data, even though you think you are.
I would suggest that you select the "name" column itself, and the LEFT'd version at the same time. You can also try to use SUBSTRING(name, 1, 1) instead of LEFT. And finally you could enclose the results in quotes to verify that you aren't just being returned a space. CONCAT("'", LEFT(name, 1), "'") as "newName".
Otherwise, I don't really have any ideas for what could be your problem without more data.
CFMaBiSmAd
10-24-2006, 04:35 AM
I ran this query using PHP and the mysql query browser and it returned the expected results (mysql 5.0.x) -
SELECT Left(name,1) AS newName FROM my_table
Gave these results -
newName
F
C
B
F
B
C
W
S
guelphdad
10-24-2006, 06:39 AM
try changing the 1 to a 2. that way if there are only spaces in the first spot then you will see the second chracter.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.