SQL I hate you.. but lets be friends
I have to admit that today I spent about 2 hours trying to get an sql script to work along with working out MYSQLi errors i kept getting. SQL i hear you all cry but how can that be troublesome? Surely you just say search for this and give me this!?!?!
Well you would think, I have written the same script about 15/16 times in different ways trying to get it to return the information I want but all to no avail. Until a friend suggested using something in SQL that I had never used before. I had been trying to achieve my goal with all manner on joins and group by clauses and such but none of it wanted to play ball.
I had set up a very distinct set of info in the DB and I knew what my result should be, I even set up a couple of other alternative results which woudl show if i was getting close. But I never got back anything that resembled what i was looking for.
My other issue was that mysqli wasnt letting me run the page the way i was used to with the old mysql link to the DB so i kept having to rethink things. Then like i said a friend suggested using a join. I pointed out I had tried that but because the information wasnt that directly linked I ket getting random results.
He then suggested a couple of other things on the join, none of that worked. At which time he reminded me about group_concat. Using it managed to get me the answers i wanted but not in the way I was expecting. So add in a couple of extra php functions i quickly put together and boom. 1 SQL statement was doing what I was trying to achieve with 2. Admittedly the returned result wasn't in the desired format but it meant i got the answer i was looking for and with a little extra work it all ended up fine.