dbTalk Databases Forums  

Update and select in the same request

comp.databases.mysql comp.databases.mysql


Discuss Update and select in the same request in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Julien Arlandis
 
Posts: n/a

Default Update and select in the same request - 11-17-2010 , 02:51 AM






Hello,

Sometimes I need to update datas just after a select, for example :

SELECT * FROM users WHERE login = 'the_login' and password = 'the_password';

and

UPDATE users SET date_connexion = NOW();

To take the network load, is it possible to send this two requests using
just one request TCP with mysql server? In my case the client is PHP
with dbo object.

Thanks.

Reply With Quote
  #2  
Old   
RE
 
Posts: n/a

Default Re: Update and select in the same request - 11-17-2010 , 03:31 AM






Mcse <a href="http://example.com">Example</a>

Submitted via EggHeadCafe
ASP.NET Sum of Numbers Captcha Control with CustomValidator
http://www.eggheadcafe.com/tutorials...validator.aspx

Reply With Quote
  #3  
Old   
Beauregard T. Shagnasty
 
Posts: n/a

Default Re: Update and select in the same request - 11-17-2010 , 03:40 AM



Julien Arlandis wrote:

Quote:
Sometimes I need to update datas just after a select, for example :

SELECT * FROM users WHERE login = 'the_login' and password = 'the_password';
What do you expect to happen if this first query fails to find a user?

Quote:
and

UPDATE users SET date_connexion = NOW();

To take the network load, is it possible to send this two requests
using just one request TCP with mysql server? In my case the client
is PHP with dbo object.
Your second query would update all the records in the table, as I see
it. You need to check first if the SELECT actually found the (a)
particular user whose record matches the login and password.

--
-bts
-Four wheels carry the body; two wheels move the soul

Reply With Quote
  #4  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: Update and select in the same request - 11-17-2010 , 06:59 AM



Julien Arlandis wrote:
Quote:
Hello,

Sometimes I need to update datas just after a select, for example :

SELECT * FROM users WHERE login = 'the_login' and password =
'the_password';

and

UPDATE users SET date_connexion = NOW();

To take the network load, is it possible to send this two requests using
just one request TCP with mysql server? In my case the client is PHP
with dbo object.

Thanks.
UPDATE users SET date_connexion=NOW()
WHERE login = 'the_login'
and password = 'the_password';

Reply With Quote
  #5  
Old   
Julien Arlandis
 
Posts: n/a

Default Re: Update and select in the same request - 11-17-2010 , 05:17 PM



Le 17/11/2010 13:59, The Natural Philosopher a écrit :
Quote:
UPDATE users SET date_connexion=NOW()
WHERE login = 'the_login'
and password = 'the_password';
Ok but I want to execute a select to display other information as name,
sex...

Reply With Quote
  #6  
Old   
Doug Miller
 
Posts: n/a

Default Re: Update and select in the same request - 11-17-2010 , 06:42 PM



In article <4ce46285$0$5432$ba4acef3 (AT) reader (DOT) news.orange.fr>, Julien Arlandis <julien.arlandis@.laposte.net> wrote:
Quote:
Le 17/11/2010 13:59, The Natural Philosopher a écrit :

UPDATE users SET date_connexion=NOW()
WHERE login = 'the_login'
and password = 'the_password';

Ok but I want to execute a select to display other information as name,
sex...
Then execute a SELECT to display that other information.

UPDATE is for updating rows. SELECT is for retrieving them. They have two
different functions. Neither one can do the job of the other.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.