Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top