mysql if exists
hello all,
I have a bit of a strange mysql query that I am trying to run, basically the pseudo code would be: Code:
select c.id, c.name |
Good to know. Glad you don't need any help with anything...
:-) Seriously, is there a question in there somewhere? Are you asking a question??? |
Hello, yes sorry the question is; how can I get that statement to work? Is there a way?
|
there are control flow functions in mysql:
http://dev.mysql.com/doc/refman/5.0/...functions.html You may want to exchange the "5.0" in the link with the mysql version you are using. |
Hi Cheers, I have taken a look but I am still unsure as to use it the the way that I am attempting, I dont suppose you have an example that I can use do you? Many thanks in advance....
|
I'm working with scripting languages as PHP or Perl so I don't have examples that could be useful for you, sorry.
|
trscookie,
One of the problems with pseudo-code is that it has no defined syntax, so it is perhaps too open to interpretation. :-) mysql has EXISTS which can be negated as NOT EXISTS, also if statements, a case statement, which is almost like a switch statement in some languages, or a case construct in bash. If I'm thinking correctly, and if I'm interpreting your pseudo-code correctly, I would focus on a simplified form of the conditional part of it: Code:
if TRUE Code:
and c.name = 'variable' Code:
and c.id in (select id from another_table) Code:
select c.id, c.name Code:
select c.id, c.name If the statements I illustrated help you at all, then great. If they don't help, perhaps you could provide a textual, not pseudo-code description, with the specifics of what you are trying to accomplish. |
All times are GMT -5. The time now is 05:15 AM. |