Re: Newbie - CREATE VIEW Question
Rob Desbois schrieb: To those who responded - read the question. He wants to combine the values from the data column of *2* rows into one, not just a straightforward string concatenation. Sorry but you want me to write the whole SQL query? He has to use his brain. Grouping and joining the tables. I'm not here for doing your or his work! Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
Rob Desbois schrieb: Sorry but you want me to write the whole SQL query? He has to use his brain. Grouping and joining the tables. I'm not here for doing your or his work! Barry, I agree that it's often better to point someone in the right direction rather than just writing the query for them, but in this case it was a newbie question. And therefore it's most important that he tries to learn how to look at the doc. Or your newbies will start asking every shit on List because the don't know what to do else. From where I saw it, the difficulty was in concatenating values from 2 rows, not the concatenation itself. That is why I thought your response was not sufficient. Apologies if I caused any offense. Well it was to be exact concating 2 tables with their rows. Well your post was also not sufficient, because you didn't helped him at all, too. So what do we learn about this? Nothing. It's internet! Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
Rob Desbois schrieb: I agree that it's often better to point someone in the right direction rather than just writing the query for them, but in this case it was a newbie question. And therefore it's most important that he tries to learn how to look at the doc. Remembering my own troubles learning MySQL, it can be difficult to know *what* to search for - if this person is completely new to SQL, the concept of joining a table to itself might not occur. That's why i gave a hint of where to look. Or your newbies will start asking every shit on List because the don't know what to do else. I know, it is annoying answering questions just because someone can't be bothered. I don't answer them. It's just annyoning to see the list overflowing with posts that had been easily done looking at the docs for a few minutes. From where I saw it, the difficulty was in concatenating values from 2 rows, not the concatenation itself. That is why I thought your response was not sufficient. Apologies if I caused any offense. Well it was to be exact concating 2 tables with their rows. Well your post was also not sufficient, because you didn't helped him at all, too. Yes, I know my post didn't answer the question either :) I mailed because I thought you might've misunderstood the original question and thought it was just about how to concatenate two strings, rather than the more difficult joining part. Well more difficult is relative. Did not misunderstood. Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Newbie - CREATE VIEW Question
Search the Manual for CONCAT. SELECT /Peter -Original Message- From: z247 [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 04, 2006 10:02 PM To: mysql@lists.mysql.com Subject: Newbie - CREATE VIEW Question Say I have the following tables; siteID,name -- site1, XYZ site2, RSQ ID,site,data 1, site1, M 2, site2, Q 3, site2, Y 4, site1, P ... etc. And I want to create a view like this; siteID,name,data -- site1, XYZ, (M,P) site2, RSQ, (Q,Y) where all the related column data in the second table is placed in another column. How can I do this? Is there a function that can group these values into one variable or array? Thank you -- View this message in context: http://www.nabble.com/NewbieCREATE-VIEW-Question-tf1890326.html#a5168593 Sent from the MySQL - General forum at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
z247 schrieb: Say I have the following tables; siteID,name -- site1, XYZ site2, RSQ ID,site,data 1, site1, M 2, site2, Q 3, site2, Y 4, site1, P ... etc. And I want to create a view like this; siteID,name,data -- site1, XYZ, (M,P) site2, RSQ, (Q,Y) where all the related column data in the second table is placed in another column. How can I do this? Is there a function that can group these values into one variable or array? Thank you CONCAT_WS(', ',siteID,name,data) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
Hi, Say I have the following tables; siteID,name -- site1, XYZ site2, RSQ ID,site,data 1, site1, M 2, site2, Q 3, site2, Y 4, site1, P ... etc. And I want to create a view like this; siteID,name,data -- site1, XYZ, (M,P) site2, RSQ, (Q,Y) where all the related column data in the second table is placed in another column. How can I do this? Is there a function that can group these values into one variable or array? Requires 4.1 or higher: SELECT table1.siteID, table1.name, GROUP_CONCAT(table2.data SEPARATOR ,) AS all_data FROM table1 JOIN table2 ON table1.siteID=table2.site GROUP BY table1.siteID Regards, Jeremy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
Thank you! -- View this message in context: http://www.nabble.com/NewbieCREATE-VIEW-Question-tf1890326.html#a5171108 Sent from the MySQL - General forum at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie - CREATE VIEW Question
Hi, the GROUP_CONCAT worked. Thank you. However, I'm getting duplicates in the all_data column. Is there a function like array_unique in PHP to remove these duplicates? I tried DISTINCT but that did not work. Thank you. -- View this message in context: http://www.nabble.com/NewbieCREATE-VIEW-Question-tf1890326.html#a5171910 Sent from the MySQL - General forum at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]