vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have three tables (x, y, and z) with the same 3 fields (id, name, number). If I do: SELECT * FROM x, y, z WHERE ... each row of my result will contain 3 id fields, 3 name fields, and 3 number fields. Of course, I can/should do: SELECT x.id AS x_id, x.name AS x_name, x.number AS x_number, y.id AS y_id, y.name AS y_name, y.number AS y_number, z.id AS z_id, z.name AS z_name, z.number AS z_number FROM x, y, z WHERE ... Short of scripting, is there any way to get MySQL to do this? Something like: SELECT * FROM x, y, z PREFIX FIELDS WITH TABLE NAME WHERE ... -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. |
| ||||
| Hi Kelly, The short script of prefixing fields with tablename till 5.0 and beta is not applicable. Hope, this senario would be rare, that too many tables with larger field length, more columns etc. Thanks ViSolve DB Team ----- Original Message ----- From: "Kelly Jones" <kelly.terry.jones@gmail.com> To: <mysql@lists.mysql.com> Sent: Monday, December 11, 2006 8:39 PM Subject: Prefixing fields with table name when joining? >I have three tables (x, y, and z) with the same 3 fields (id, name, > number). If I do: > > SELECT * FROM x, y, z WHERE ... > > each row of my result will contain 3 id fields, 3 name fields, and 3 > number fields. > > Of course, I can/should do: > > SELECT x.id AS x_id, x.name AS x_name, x.number AS x_number, > y.id AS y_id, y.name AS y_name, y.number AS y_number, > z.id AS z_id, z.name AS z_name, z.number AS z_number > FROM x, y, z WHERE ... > > Short of scripting, is there any way to get MySQL to do this? Something > like: > > SELECT * FROM x, y, z PREFIX FIELDS WITH TABLE NAME WHERE ... > > -- > We're just a Bunch Of Regular Guys, a collective group that's trying > to understand and assimilate technology. We feel that resistance to > new ideas and technology is unwise and ultimately futile. > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=m...rt@visolve.com > |