In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
It is believed that many inexperienced people don't know what to do about how to merge the same field values of multiple lines of records in SQL. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. Query the eligible records from the database and store them in a DataTable. After traversing the table using c #, etc., use the primary key in DataRow to read the corresponding qualified records, merge the records read for the second time, and return them to the previous DataRow data row. There is nothing wrong with this, but if the amount of data is large, we may face countless times to open and disconnect the database, which will be very inefficient. two。 Read the data from the database one table at a time and display it to the UI layer. It is said that everyone wants to do this, but in the past, I was too stupid to study this. Today, because of the large amount of data, I have to think of other ways to improve efficiency. Google~hk, I really have the answer, and then I wrote a part-time record in order to obtain an unlimited number of eligible part-time jobs, and record each part-time participation project in several fields. Then return Table once and copy the code as follows: Create function Fn_GetJobListByPID-- creates a custom function to get the number and number of all projects that you specify part-time to participate in (@ ParttimerID int) returns @ t table (Jobs varchar (5000), ParttimerID int,TotalCount int) as begin declare @ sql varchar (5000), @ TotalCount int set @ sql='' set @ TotalCount=0 select @ sql=@sql+j.JobNo+'-'+j.JobWave+'', @ TotalCount=@TotalCount+1 from ONJB_JobApplication a ONJB_Jobs j where a.ParttimerID=@ParttimerID and a.Resultinitiate V'and a.JobID=j.JobID insert @ t values (@ sql,@ParttimerID,@TotalCount) return end
The reference copy code is as follows: -. -- done project left join (select Jobs,ParttimerID,TotalCount From Fn_GetJobListByPID (@ ParttimerID)) as J1 on p.ParttimerID=j1.ParttimerID-- doing project left join (select CurJobs,ParttimerID,CurCount From Fn_GetCurJobsByPID (@ ParttimerID)) as J2 on p.ParttimerID=j2.ParttimerID where p.ParttimerID=@ParttimerID
After reading the above, have you mastered the method of how to merge the same field values of multiple lines of records in SQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.