Solved

& Ampersand in MYSQL CANCAT()

Posted on 2009-07-15
4
904 Views
Last Modified: 2012-08-14
How do you escape a & ampersand in mySQL, I have something like the following but need to have a ampersand in the CONCAT(), I have tried escaping \ but that does not work.

SELECT modules.URLvalue, modules.filepath, modules.id, CONCAT( modules.URLvalue,'\&pgid',modules.id) AS link
0
Comment
Question by:dstubblefield65
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 24863436
If it is URL I would try %26 instead of &. (I am too lazy to test it, MySql is not installed here, sorry.)
0
 

Author Comment

by:dstubblefield65
ID: 24863814
I tried the %26, also the & an neither worked, all i get with the %26 is %26
0
 
LVL 41

Accepted Solution

by:
pcelba earned 250 total points
ID: 24864263
What about CHAR() function?

SELECT modules.URLvalue, modules.filepath, modules.id, CONCAT( modules.URLvalue, CHAR(38), 'pgid', modules.id) AS link
0
 

Author Comment

by:dstubblefield65
ID: 24864543
That did the trick, hadn't thought of the ASCII character sets
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PDO and Database 1 88
Top 100 6 103
spx for moving values to new table 5 59
null value 15 62
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now