fre 2006-06-23 klockan 01:52 -0400 skrev Michael Stassen:
Thomas Lundström wrote:
Not sure what you're aming for here and how your data is structured but
why not use a join and alias and fetch all info in one select and then
solve what you need in your code?
Something in the line
and string functions.
-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 21, 2006 4:43 PM
To: [EMAIL PROTECTED]; Song Ken Vern-E11804
Cc: mysql@lists.mysql.com
Subject: RE: if else statement
SELECT IF(col1=3, (Select col2 from table2 where table2.id = 1
Song Ken Vern-E11804 wrote:
Hi,
I'm trying to build a query in using SQL instead of doing it in Perl.
I am trying to do something like this :
If ((select col1 from table1 where id = 1) == 3)
Then
Select col2 from table2 where table2.id = 1;
Else
Select col2 from table3 where table3.id
Hi,
I'm trying to build a query in using SQL instead of doing it in Perl.
I am trying to do something like this :
If ((select col1 from table1 where id = 1) == 3)
Then
Select col2 from table2 where table2.id = 1;
Else
Select col2 from table3 where table3.id = 1;
In Perl I would probably do
On Wednesday 21 June 2006 11:16, Song Ken Vern-E11804 wrote:
Hi,
I'm trying to build a query in using SQL instead of doing it in Perl.
I am trying to do something like this :
If ((select col1 from table1 where id = 1) == 3)
Then
Select col2 from table2 where table2.id = 1;
Else
Select
Not sure what you're aming for here and how your data is structured but
why not use a join and alias and fetch all info in one select and then
solve what you need in your code?
Something in the line of:
select t2.col2 from_t2, t3.col2 from_t3
from table1 t1, table2 t2, table3 t3
where t1.id =
Cc: mysql@lists.mysql.com
Subject: Re: if else statement
Not sure what you're aming for here and how your data is structured but
why not use a join and alias and fetch all info in one select and then
solve what you need in your code?
Something in the line of:
select t2.col2 from_t2, t3.col2
is the
only way (or the best) I will have to upgrade the server. If there is
another way to do the same thing, please let me know.
Mike
From: Egor Egorov [EMAIL PROTECTED]
Date: Mon, 26 Jan 2004 15:40:54 +0200
To: [EMAIL PROTECTED]
Subject: Re: If Else statement
Mike Tuller [EMAIL
Mike Tuller [EMAIL PROTECTED] wrote:
I am trying write a shell script to check to see if a record exists and if
it does, update information, and if it doesn't insert information. Is there
a way to do an if else statement in MySql?
If you have PRIMARY KEY or UNIQUE index, take a look
I am trying write a shell script to check to see if a record exists and if
it does, update information, and if it doesn't insert information. Is there
a way to do an if else statement in MySql?
I'm stuck on how to do this. I don't want to write it in perl.
Mike
--
MySQL General Mailing List
I am trying to update/insert a record into the table depending on whether it
exists in the table or not.
Something along the lines of...
IF (SELECT id FROM myable WHERE id=myid)
INSERT INTO mytable(id,name) VALUES (myid, myname)
ELSE
UPDATE mytable SET name=mynewname WHERE id =
See the REPLACE command: http://www.mysql.com/doc/en/REPLACE.html
---
I am trying to update/insert a record into the table depending on whether
it
exists in the table or not.
Something along the lines of...
IF (SELECT
Hi Rob,
i think to use REPLACE would do, if there is a unique index on myid:
REPACE mytable (myid, myname) VALUES (myid, mynewname);
The Manual say in chapter 6.4.8:
REPLACE works exactly like INSERT, except that if an old record in the table
has the same value as a new record on a UNIQUE index
13 matches
Mail list logo