I have the following SQL query:

SELECT p.id, title, l.id, username FROM photoTable p JOIN userTable l ON (l.id = p.iduser) ORDER BY p.id DESC LIMIT 50

I need to change the p.id to p.IdPhoto but the problem is that I only want this done temporarily within the call. I have seen ALTER TABLE as an option, but I am a bit unsure of how I can do this without altering both id fields. Any ideas?

有帮助吗?

解决方案

Would this work?

SELECT p.id as idPhoto, title, l.id, 
username 
FROM photoTable p 
JOIN userTable l ON (l.id = p.iduser) 
ORDER BY p.id DESC LIMIT 50
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top