Darshan Darshan - 1 year ago 68
SQL Question

SQL 'AS' statement Error in MySQL

I am trying to do the following sql to return 3 latest blog details from MySQL database, though getting the error, what I am missing here?

SELECT tblpost_id,
'post_contentL' AS substr(post_content,1,23)
FROM tblpost
ORDER BY tblpost_id DESC

I tried in the sql command window and its giving me the error as

#1064 - Erreur de syntaxe près de 'SUBSTR(post_content,1,23) FROM tblge_post ORDER BY tblge_post_id DESC LIMIT 3' à la ligne 1

and in the php I am trying the following code to display it, * all the mysql php retrieval objects are working fine.


Please help me to identify the problem.

Answer Source

It is the other way round. Substitute this:

'post_contentL' AS SUBSTR(post_content,1,23)


SUBSTR(post_content,1,23) AS post_contentL
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download