brown2005 Posted January 18, 2007 Share Posted January 18, 2007 $sql = "SELECT LEFT(websites_url, 1) AS 'websites_url_letter', websites_url FROM websites [b] WHERE websites_url_letter='$letter' [/b] ORDER BY websites_url ASC;";hi it says #1054 - Unknown column 'websites_url_letter' in 'where clause' is there any way round this please? Quote Link to comment Share on other sites More sharing options...
Crimpage Posted January 18, 2007 Share Posted January 18, 2007 You have to use the original column name.$sql = "SELECT LEFT(websites_url, 1) AS 'websites_url_letter', websites_url FROM websites WHERE websites_url='$letter' ORDER BY websites_url ASC;";You might be able to use the HAVING clause. I don't know the specifics of it, but someone else might be able to let us know if it will work.Cheers,Dave. Quote Link to comment Share on other sites More sharing options...
jeka911 Posted January 18, 2007 Share Posted January 18, 2007 [quote author=brown2005 link=topic=123062.msg508214#msg508214 date=1169162562]$sql = "SELECT LEFT(websites_url, 1) AS 'websites_url_letter', websites_url FROM websites [b] WHERE websites_url_letter='$letter' [/b] ORDER BY websites_url ASC;";hi it says #1054 - Unknown column 'websites_url_letter' in 'where clause' is there any way round this please?[/quote]$sql = "SELECT LEFT(websites_url, 1) AS 'websites_url_letter', websites_url FROM websites [b] WHERE LEFT(websites_url, 1)='$letter' [/b] ORDER BY websites_url ASC;";or something like:$sql = "SELECT LEFT(websites_url, 1) AS 'websites_url_letter', websites_url FROM websites [b] WHERE websites_url LIKE '$letter%' [/b] ORDER BY websites_url ASC;"; Quote Link to comment Share on other sites More sharing options...
brown2005 Posted January 19, 2007 Author Share Posted January 19, 2007 yeah cool that works, right but now i have a function calledStripUrl();which removes the first part of a url sayhttp://www.url.comand function leavesurl.comnow i want to do the LEFT(websites_url, 1) as 'websites_url_letter' on url.com and not http://www.url.comany ideas please? Quote Link to comment Share on other sites More sharing options...
bibby Posted January 21, 2007 Share Posted January 21, 2007 No No No.The error is here.$sql = "SELECT LEFT(websites_url, 1) AS [b]'websites_url_letter'[/b], websites_url FROM websites WHERE websites_url_letter='$letter' ORDER BY websites_url ASC;";Drop those quotes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.