MySQL Forums
Forum List  »  Stored Procedures

These one will be HARD
Posted by: José Nazário
Date: January 16, 2012 05:41PM

I need a sp that return something like these
where there a join with return a row true, where not a join he return a row False
Has you can see i came up with these prototype it work but probly is possible to simplify. The output is something like that. These gonna be apply to a "combocheckbox" generic type of obj
Places where i been
Name Check
Lisbon, true
France, true
London, False
USA, False
Iraq, False
YourHome, True

I have table where i keep every possible value with
Name
Lisbon
France
London
USA
Iraq
YourHome

I have a relation table where i keep the places i had been
Lisbon
France
YourHome

Now you think why i want these. These is just a exemple...! Got it
When i join "=" to table together i need to know where was a sucess join and output True, or False

If you think about you can use any two table that have relationships of any database.

Pay attention the code below isn´t using the tables in described as a exemple. Its was much complicated to put the real table on the post.

NOte: In oracle you probly resolve these simple with a MINUS don´t and a DECODE but these is MySQL.


SELECT conhecimentos_musicais,
IF (STRCMP(n_inscricao_interno,n_inscricao_interno), 'dummy', 'TRUE') AS CHECKED,
n_inscricao_interno
FROM conhecimentosmusicais_r
WHERE n_inscricao_interno = 12715
UNION
SELECT conhecimentos_musicais, 'FALSE' ,'dummy2'
FROM conhecimentosmusicais
WHERE conhecimentos_musicais NOT IN (SELECT conhecimentos_musicais
FROM conhecimentosmusicais_r
WHERE n_inscricao_interno = 12715)


Thanks for help me.

Options: ReplyQuote


Subject
Views
Written By
Posted
These one will be HARD
1452
January 16, 2012 05:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.