Use CONCAT to include text in SELECT results in MySQL

Function CONCAT allows the SELECT statements to act like printf commands by ataching text results to query results and so on

Example :

Generate a list of links in HTML from a table ‘mylinks’ with the columns ‘urls’ ( with ‘title’ (Open Software Solutions)

The output will look like this :

<a href=””>Open Software Solutions</a><br />

To do this you must use a select statement like:

SELECT CONCAT(‘<a href=”‘, urls, ‘”>’, title, ‘</a><br />’) FROM mylinks;

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

To prove that you're not a bot, enter this code
Anti-Spam Image