SELECT TO REDUCE SEVERAL SIMILAR MYSQL ENTRIES

Asked

Viewed 56 times

0

Good morning guys, I have searched and found nothing very useful. I have an inventory database of my Network Stations. The agent installed on each station sends the installed program names to the table software name.. When I make a select, comes several similar inputs, as:

  • Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.40660,
  • Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.40660,
  • Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.40660,
  • Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.40660,
  • Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.40660;

When the ideal would be to have only one way out

"Microsoft Visual C++ 2013"

You can do it?
Follow my select:

SELECT s.NAME 
FROM hardware as h, softwares as s 
WHERE h.ID = s.HARDWARE_ID
ORDER BY s.NAME
  • What is your goal exactly? Just pick up the text Microsoft Visual C++? Or there may be entries with different text?

  • My goal is to get almost equal entries reduced to a single, like: Microsoft Office 2016 , Microsoft Office 2016 exchange 12346 skirt as Microsoft Office 2016 only.

  • There’s no search pattern, I don’t think you’ll be able to do that!

  • Actually I imagine it is something more relative to strings and treat the output. Where when there are two outputs nome123 and nome231 would be treated to be shown as nome

1 answer

0

You can use a substring with subselect to do this:

SELECT DISTINCT X.NAME FROM
(
SELECT h.HOST, substring(s.NAME,1, 25) AS NAME
FROM hardware as h, 
softwares as s 
WHERE h.ID = s.HARDWARE_ID AND ORDER BY s.NAME
) as x
  • The substring function would give me solution only to the cases in which they appear Microsoft Visual C++ 2013 x86 Minimum Runtime , but when you show up Microsoft Office 2016 (x64), Microsoft Office 2016 exchange ultimate (x86) no longer answers. I would like a solution that would give me a return of a single output for equal or similar names.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.