I have a table with products related to an idpage like this:
+--------+-----------+-------------+-------------+
| idPage | idProduct | inputedName | inputedCode |
+--------+-----------+-------------+-------------+
| 25 | 60 | x | 8924 |
| 26 | 65 | y | 105555 |
| 26 | 70 | z | 105555 |
| 27 | 33 | a | 14151112 |
| 27 | 34 | a | 14151112 |
| 27 | 22 | a | 14151112 |
| 27 | 17 | b | OS987456 |
| 27 | 18 | c | |
| 27 | 17 | | |
| 27 | 23 | a | 14151112 |
+--------+-----------+-------------+-------------+
There is no id Unique.
The user input InputedName and InputedCode on a form.
What I want to do on page view is select DISTINCT combination of InputedName x Inputed Code and intersect or inner join (or whatever) with all related itens to show something like:
In idPage=27:
- a 141511112 (inputedName, inputedCode)
-- 33 (idProduct)
-- 34
-- 22
-- 23
- b OS987456
-- 17
- c (null)
-- 18
- (null)(null)
-- 17
Is there a great way to do that or the basic way is the best? Basic way, I mean, I’m using PHP. I would first select Distinct combination of inputedName with inputedCode (I still don’t know how to do it with my table) and into while command of PHP I would do another query. In this case it would do 5 queries. I don’t think it is a ellegant solution, but as I know mysql is powerful, maybe there is another way.
I’m confused of what you are asking for but let me give this a try:
SQLFiddle Demo (Click Here)