Reputation: 31
I've created a front end table with the following code. It's working great. But what I want to do is add a link to member's profiles based on their user_id. We view member profiles by visiting http://example.com/profile/?profile=642 (642 being the user_id) So, I want to add "http://example.com/profile/?profile=" in front of the m4.user_id in my table. Any help would be appreciated.
SELECT
DISTINCT
u1.id,
u1.user_login,
u1.user_registered,
u1.user_email,
u1.user_url,
m1.meta_value AS firstname,
m2.meta_value AS lastname,
m3.meta_value AS mepr_region,
m4.user_id,
t1.status,
t2.expires_at
FROM wp_acfzia_users u1
JOIN wp_acfzia_usermeta m1 ON (m1.user_id = u1.id AND m1.meta_key = 'first_name')
JOIN wp_acfzia_usermeta m2 ON (m2.user_id = u1.id AND m2.meta_key = 'last_name')
JOIN wp_acfzia_usermeta m3 ON (m3.user_id = u1.id AND m3.meta_key = 'mepr_region')
JOIN wp_acfzia_usermeta m4 ON (m4.user_id = u1.id)
JOIN wp_acfzia_mepr_transactions t1 ON (t1.id = u1.id)
JOIN wp_acfzia_mepr_transactions t2 ON (t2.id = u1.id)
WHERE m3.meta_value = 'aimga-south'
Upvotes: 1
Views: 2672
Reputation: 15384
Use Mysql's CONCAT
function to concatenate two strings:
SELECT
m4.user_id,
CONCAT('http://example.com/profile/?profile=', m4.user_id) as profile_url
...
Mysql will automatically cast your id integer to a string to concatenate.
Upvotes: 4