我已经查看过几个连接问题,似乎无法让这些解决方案适合我。
case "tblContestant":
$sql = "SELECT e.id as Id,@n := @n + 1 n, replace(c.name, ',', ' ') as name, c.address, NULL, c.city, c.state, c.phonenumber, c.email, c.sanctionbody, concat(c.id,c.sanctionnumber) as sanctionnumber, mcrc.amount, c.zip, c.jrboater
FROM contestants c
LEFT JOIN main_contestant_register_class mcrc ON mcrc.contestant_id = c.id
LEFT JOIN events e ON e.id = mcrc.event_id, (SELECT @n := 0) m
WHERE e.id = $id";
上面给出了将c.id与c.sanctionnumber(142155)结合起来的结果,但是我想在c.id和c.sanctionnumber之间有一个空格。 (14 - 2155)或(14-2155)如果不能选择空格。
提前致谢!
答案 0 :(得分:0)
case "tblContestant":
$sql = "SELECT e.id as Id,@n := @n + 1 n, replace(c.name, ',', ' ') as name, c.address, NULL, c.city, c.state, c.phonenumber, c.email, c.sanctionbody, concat(c.id,' - '+ c.sanctionnumber) as sanctionnumber, mcrc.amount, c.zip, c.jrboater
FROM contestants c
LEFT JOIN main_contestant_register_class mcrc ON mcrc.contestant_id = c.id
LEFT JOIN events e ON e.id = mcrc.event_id, (SELECT @n := 0) m
WHERE e.id = $id";
答案 1 :(得分:0)
Avi感谢您的帮助,问题得到了解决!我只是将+改为a,现在它给了我想要的结果。
concat(c.id,' - '+ c.sanctionnumber) as sanctionnumber, gives me 142155
concat(c.id,' - ', c.sanctionnumber) as sanctionnumber, gives me 14 - 2155