Re: [PHP] MySql help #1

2001-08-03 Thread elias

Miles,

The LIMIT works great with UPDATE too.

Miles Thompson [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Come on, you're pushing SQL in directions it's not supposed to go! It is
 set oriented after all.
 So it's experimentation time. I've never tried, but as LIMIT works on a
 SELECT, try it on an update. And let us know what happened.
 Miles

 At 10:30 AM 8/2/01 +0200, elias wrote:
 How can I update only N fields from the database?
 
 usually we do:
 
 UPDATE table1 SET field='VALUE' WHERE condition1
 
 now I want to update fields with a certain condition but only X fields
out N
 total fields.
 
 ie:
 
 id   value
 --- ---
 1a
 2b
 3c
 4d
 5e
 
 how can i update such like:
 UPDATE table1 SET {only 2 records} value='aa'
 so I have any two fields now have the 'aa' value
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySql help #1

2001-08-03 Thread Miles Thompson


Come on, you're pushing SQL in directions it's not supposed to go! It is 
set oriented after all.
So it's experimentation time. I've never tried, but as LIMIT works on a 
SELECT, try it on an update. And let us know what happened.
Miles

At 10:30 AM 8/2/01 +0200, elias wrote:
How can I update only N fields from the database?

usually we do:

UPDATE table1 SET field='VALUE' WHERE condition1

now I want to update fields with a certain condition but only X fields out N
total fields.

ie:

id   value
--- ---
1a
2b
3c
4d
5e

how can i update such like:
UPDATE table1 SET {only 2 records} value='aa'
so I have any two fields now have the 'aa' value





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySql help #1

2001-08-03 Thread elias

the structur is like:
 id, item name, items in stock , frogserialnumber, status
 1,  frog,  7, 002121, Reserved
2,  frog,  7, 101011, Free
1,  frog,  7, 212001, Free

that's why I want to mark only N entries Reserved,

Lawrence Sheed [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]
...
 Have you thought about your database design carefully?

 You might want to create a column for item count

 eg

 id, item name, items in stock
 1,  frog,  7

 if, say a customer orders 3 frogs, decrement the items in stock by 3.

 Just an idea...

 Do you know about database normalization?  How is the database designed?



 -Original Message-
 From: elias [mailto:[EMAIL PROTECTED]]
 Sent: August 2, 2001 6:32 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] MySql help #1


 Someone purchased items from my site let's say 3 items out of 5 total. All
 items are the same. I just want to update 3 items status to Reserved.
 When he buy he just tell how many and not which ones.

 Lawrence Sheed [EMAIL PROTECTED] wrote in message

[EMAIL PROTECTED]">news:[EMAIL PROTECTED]
 ..
  Sounds like a strange request, what are you trying to do?
 
  I don't think you can do this directly in mysql, but you could build an
  array of results in php.
 
  eg something like (crappy code below)
 
  //Grab results
  $db = mysql_connect($db_domain, $db_user,$db_password);
  mysql_select_db($db_databasename,$db);
  $sqlquery=select ID from table1 where condition1;
  $result = mysql_query ($sqlstring,$db);
  $count=0;
  while ($resultset = mysql_fetch_array ($result)) {
  $array[$count]=$resultset [ID];
  $count++;
  }
 
 
  for ($count=0;$count2;$count++){
  update table1 set field='VALUE' WHERE ID=.$array[$count];
  $result = mysql_query ($sqlstring,$db) or die (mysql_error());
  }
 
  -Original Message-
  From: elias [mailto:[EMAIL PROTECTED]]
  Sent: August 2, 2001 4:30 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] MySql help #1
 
 
  How can I update only N fields from the database?
 
  usually we do:
 
  UPDATE table1 SET field='VALUE' WHERE condition1
 
  now I want to update fields with a certain condition but only X fields
out
 N
  total fields.
 
  ie:
 
  id   value
  --- ---
  1a
  2b
  3c
  4d
  5e
 
  how can i update such like:
  UPDATE table1 SET {only 2 records} value='aa'
  so I have any two fields now have the 'aa' value
 
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] MySql help #1

2001-08-02 Thread elias

How can I update only N fields from the database?

usually we do:

UPDATE table1 SET field='VALUE' WHERE condition1

now I want to update fields with a certain condition but only X fields out N
total fields.

ie:

id   value
--- ---
1a
2b
3c
4d
5e

how can i update such like:
UPDATE table1 SET {only 2 records} value='aa'
so I have any two fields now have the 'aa' value





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] MySql help #1

2001-08-02 Thread Lawrence . Sheed

Sounds like a strange request, what are you trying to do?

I don't think you can do this directly in mysql, but you could build an
array of results in php.

eg something like (crappy code below)

//Grab results
$db = mysql_connect($db_domain, $db_user,$db_password);
mysql_select_db($db_databasename,$db);
$sqlquery=select ID from table1 where condition1;
$result = mysql_query ($sqlstring,$db);
$count=0;
while ($resultset = mysql_fetch_array ($result)) {
$array[$count]=$resultset [ID];
$count++;
}


for ($count=0;$count2;$count++){
update table1 set field='VALUE' WHERE ID=.$array[$count];
$result = mysql_query ($sqlstring,$db) or die (mysql_error());
}

-Original Message-
From: elias [mailto:[EMAIL PROTECTED]]
Sent: August 2, 2001 4:30 PM
To: [EMAIL PROTECTED]
Subject: [PHP] MySql help #1


How can I update only N fields from the database?

usually we do:

UPDATE table1 SET field='VALUE' WHERE condition1

now I want to update fields with a certain condition but only X fields out N
total fields.

ie:

id   value
--- ---
1a
2b
3c
4d
5e

how can i update such like:
UPDATE table1 SET {only 2 records} value='aa'
so I have any two fields now have the 'aa' value





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySql help #1

2001-08-02 Thread elias

Someone purchased items from my site let's say 3 items out of 5 total. All
items are the same. I just want to update 3 items status to Reserved.
When he buy he just tell how many and not which ones.

Lawrence Sheed [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]
...
 Sounds like a strange request, what are you trying to do?

 I don't think you can do this directly in mysql, but you could build an
 array of results in php.

 eg something like (crappy code below)

 //Grab results
 $db = mysql_connect($db_domain, $db_user,$db_password);
 mysql_select_db($db_databasename,$db);
 $sqlquery=select ID from table1 where condition1;
 $result = mysql_query ($sqlstring,$db);
 $count=0;
 while ($resultset = mysql_fetch_array ($result)) {
 $array[$count]=$resultset [ID];
 $count++;
 }


 for ($count=0;$count2;$count++){
 update table1 set field='VALUE' WHERE ID=.$array[$count];
 $result = mysql_query ($sqlstring,$db) or die (mysql_error());
 }

 -Original Message-
 From: elias [mailto:[EMAIL PROTECTED]]
 Sent: August 2, 2001 4:30 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] MySql help #1


 How can I update only N fields from the database?

 usually we do:

 UPDATE table1 SET field='VALUE' WHERE condition1

 now I want to update fields with a certain condition but only X fields out
N
 total fields.

 ie:

 id   value
 --- ---
 1a
 2b
 3c
 4d
 5e

 how can i update such like:
 UPDATE table1 SET {only 2 records} value='aa'
 so I have any two fields now have the 'aa' value





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] MySql help #1

2001-08-02 Thread Lawrence . Sheed

Have you thought about your database design carefully?

You might want to create a column for item count  

eg

id, item name, items in stock 
1,  frog,  7

if, say a customer orders 3 frogs, decrement the items in stock by 3.

Just an idea...

Do you know about database normalization?  How is the database designed?



-Original Message-
From: elias [mailto:[EMAIL PROTECTED]]
Sent: August 2, 2001 6:32 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] MySql help #1


Someone purchased items from my site let's say 3 items out of 5 total. All
items are the same. I just want to update 3 items status to Reserved.
When he buy he just tell how many and not which ones.

Lawrence Sheed [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]
...
 Sounds like a strange request, what are you trying to do?

 I don't think you can do this directly in mysql, but you could build an
 array of results in php.

 eg something like (crappy code below)

 //Grab results
 $db = mysql_connect($db_domain, $db_user,$db_password);
 mysql_select_db($db_databasename,$db);
 $sqlquery=select ID from table1 where condition1;
 $result = mysql_query ($sqlstring,$db);
 $count=0;
 while ($resultset = mysql_fetch_array ($result)) {
 $array[$count]=$resultset [ID];
 $count++;
 }


 for ($count=0;$count2;$count++){
 update table1 set field='VALUE' WHERE ID=.$array[$count];
 $result = mysql_query ($sqlstring,$db) or die (mysql_error());
 }

 -Original Message-
 From: elias [mailto:[EMAIL PROTECTED]]
 Sent: August 2, 2001 4:30 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] MySql help #1


 How can I update only N fields from the database?

 usually we do:

 UPDATE table1 SET field='VALUE' WHERE condition1

 now I want to update fields with a certain condition but only X fields out
N
 total fields.

 ie:

 id   value
 --- ---
 1a
 2b
 3c
 4d
 5e

 how can i update such like:
 UPDATE table1 SET {only 2 records} value='aa'
 so I have any two fields now have the 'aa' value





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]