Deleting records while parsing query results (in Perl DBI)?

2003-02-28 Thread Jeff Snoxell
Hi,

If I run a mysql query then work through the results of that query one at a 
time, deleting the record sometimes eg:

while (my $href = $sth-fetchrow_hashref())
{
  if ($href-{'ExpiryDate'} eq '2003-02-22 00:00:00') {
# Do something
# then...
$db-do(DELETE FROM MyTable WHERE ID=$href-{'ID'});
  }
  else {
# Do something else
  }
}
Does the DELETE cause a change in the results of the surrounding $sth 
parsing loop?

I know it would be best to do a:

DELETE FROM MyTable WHERE ExpiryDate = whatever

But I need to use the data to do some other stuff, only from those records 
that are up for deletion.

Any ideas?

Thanks,

Jeff

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


How to query an entire row?

2003-02-24 Thread Jeff Snoxell
Hello,

In a table like this:

ID
Item1 char(100)
Item2 char(100)
.
.
ItemN char(100)
What's the cleanest way to do this mysql query:

SELECT * FROM MyTable WHERE AnyColumn LIKE '%mysearch%'

Only way I can think to do it is:

SELECT * FROM MyTable WHERE (Item1 LIKE '%mysearch%' OR Item2 LIKE 
'%mysearch%' OR  )

Many thanks,

Jeff

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


Re: Re: How to query an entire row?

2003-02-24 Thread Jeff Snoxell
At 13:53 24/02/03 +0100, you wrote:
Hello.

On Mon 2003-02-24 at 11:28:05 +, [EMAIL PROTECTED] wrote:
 Hello,

 In a table like this:

 ID
 Item1 char(100)
 Item2 char(100)
 .
 .
 ItemN char(100)

 What's the cleanest way to do this mysql query:

 SELECT * FROM MyTable WHERE AnyColumn LIKE '%mysearch%'

 Only way I can think to do it is:

 SELECT * FROM MyTable WHERE (Item1 LIKE '%mysearch%' OR Item2 LIKE
 '%mysearch%' OR  )
Yes, that's it. If you think that's unpretty, you are right. With a
normalized design, you usually shouldn't need such a query. In other
words, if you find yourself needing to do such queries regularly, you
may want to re-evaluate your database design.
Can I not do:

WHERE CONCAT(Item1,Item2,ItemN) LIKE '%mysearch%'

?

Jeff 

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


Query Help

2003-02-11 Thread Jeff Snoxell
Hi,

How can I write a MySQL query to grab single lines of the form:

ColumnNames: EnquiryID, Name, Address, Detail1, Detail2, Detail3, Detail4

From two joined tables:

Tbl1: Enquiries
--
ID
Name
Address
Etc


Tb12: Details

ID
EnquiryID
Detail
Etc


There is an imposed maximum number of details per enquiry (say 4 for this 
example).

Many thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



SET field manipulation

2003-02-11 Thread Jeff Snoxell
Hi,

how can I update a set field such that all table rows get what they had in 
the set ORed with some other set value.

I.E. If I have a field called SetField and rows:

SetField
A
A,B
A,B,C
B
etc


How can I do what I'm trying to do with this mysql query?

UPDATE MyTable SET SetField = (SetField OR 'D');

Thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Query Help

2003-02-10 Thread Jeff Snoxell
Hi,

How can I write a MySQL query to grab single lines of the form:

ColumnNames: EnquiryID, Name, Address, Detail1, Detail2, Detail3, Detail4

From two joined tables:

Tbl1: Enquiries
--
ID
Name
Address
Etc


Tb12: Details

ID
EnquiryID
Detail
Etc


There is an imposed maximum number of details per enquiry (say 4 for this 
example).

Many thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Perl DBI secret command?

2003-01-18 Thread Jeff Snoxell
Hi,

just stumbled across the following piece of code:

my $rowcount = $sth-rows();

And I checked it out compared to a count of the fetched rows from an SQL 
QUERY. AND It matched exactly!

BUT, I can't find the command rows() in the DBI documentation.

What's the story? Have I unearthed a conspiracy?


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



DBI Question?

2003-01-16 Thread Jeff Snoxell
Hi,

if I call:

my $record = $sth-fetchrow_hashref();

then:

$sth-finish();

How valid is it for me to keep referring to my $record hash pointer? 
Especially if I use $sth in a subsequent transaction.

Thanks,


Jeff Snoxell
Aetherweb Ltd
http://www.aetherweb.co.uk

NB. I know I asked this question before but nobody answered and I've tried 
looking elsewhere but can't find an answer to this anywhere. Thanks.

[SPAM FILTER FODDER: MySQL, QUERY]


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Perl DBI $sth-fetchrow_hashref() persistence?

2003-01-15 Thread Jeff Snoxell
Hi,

if I call:

my $record = $sth-fetchrow_hashref();

then:

$sth-finish();

How valid is it for me to keep referring to my $record hash pointer?

Thanks,


Jeff Snoxell
Aetherweb Ltd
http://www.aetherweb.co.uk
[SPAM FILTER FODDER: MySQL, QUERY]


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Help with SQL statement?

2003-01-15 Thread Jeff Snoxell
Hi,

I've got a varchar field in a mysql table that contains 'N' numbers (each a 
maximum of 4 digits, not zero padded) separated by spaces when more than 1 
number is present.

eg. field content might be any of the following

''
'123 4567 1234 45 3'
'3'
'3 4 6'

I want to select only those records that do not contain a certain number.

Problem I have with using LIKE %MyNum% is that obviously this is going to 
match 3 against 123 which I don't want it to.

Is there something I can use like Perl's word boundary pattern match code?

My statement so far is:

SELECT * FROM MyTable WHERE RefList NOT RLIKE \bMyNum\b # Where \b is a 
word boundary

Many thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



More: What's returned from $sth-execute(); ?

2003-01-13 Thread Jeff Snoxell
Hi,

I see your point re:

Some code to illustrate:

printf Query: %s\n, $query;
my $sth = $dbh-prepare ($query);
$sth-execute();
# metadata information becomes available at this point ...
printf NUM_OF_FIELDS: %d\n, $sth-{NUM_OF_FIELDS};
print Note: query has no result set\n if $sth-{NUM_OF_FIELDS} == 0;

but what I really want to do is determine at an early stage if I have any 
results at all in my result set. Actual reason for this is that I'm doing a 
SELECT WHERE query and scanning my entrire DB  for a session ID that 
matches one read from a cookie. I then want to determine if this is a valid 
session id and if not re-direct the user to a page saying unrecongnised 
session id or something.

Thanks,


Jeff 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



What's the point of SET fields?

2003-01-12 Thread Jeff Snoxell
Hi,

I've setup a mysql table field which is a SET type, but it seems to be 
completely pointless. I can't see why I should use a SET type rather than a 
string for the following reasons:

1. I appear to be able to store whatever I want in there. MySQL doesn't 
enforce the rule that what I stick in there must be items from the set I 
defined when I defined my field.

2. What I do a SELECT statement the only way I can interrogate records to 
determine if a certain set value is present is to do a WHERE MySet LIKE 
'%MySetMember%' which is fairly useless if set items contain other set 
items in their name (ie if I have set items A,AB,ABC then obviously 
my LIKE query searching for an A will have issues).

Or am I missing something?

Thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



What's returned from $sth-execute(); ?

2003-01-10 Thread Jeff Snoxell
Hi,

I've been using the return value of $sth-execute(); (in Perl DBI) to
determine if I have a result set. I'm not using the value I get back but am
assuming that if it's =1 then I have some results.

Is this a safe thing to do with MySQL?

And

The results do actually seem to be correct for the number of records I get
back. Should this be the case? Is it reliable?

Thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




When is learning chargeable to a client?

2003-01-08 Thread Jeff Snoxell
Hi,

I suppose this may be slightly off topic and not really relevant to a mysql 
mailing list, sorry... but...

I've spent the last month getting up to speed with MySQL with much help 
from you guys and Mr DuBois' book. I've done this because an existing 
client of mine has a system which works with a database engine we developed 
in house for cheap and cheerful little database applications but their 
requirements have increased to a point where our little engine is running 
at max throttle. I proposed that I convert their setup to work with MySQL 
and said that I would not charge for my time spent learning how to use MySQL.

My question is: when developing _any_ software it's almost always a bit of 
a learning process. I'm always referring to reference manuals etc. etc. 
whenever I'm developing, even in the languages I'm most familiar with. So 
where do I draw the line?

How can I identify a reasonable point at which it's fair to start logging 
some hours down to my client?

Many thanks,


Jeff Snoxell


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Using Perl DBI quote() method with NULL values?

2003-01-07 Thread Jeff Snoxell
Hello,

I've got a mysql table with a lot of fields and I'm using a map statement 
to pass each of my values for a new record through the quote system so-as 
to have everything nicely wrapped up. Problem is that I can't find any way 
of writing a null value to my DB when the value has first passed through 
quote().

I've tried:

my $err = $MyDatabase-do('INSERT INTO MyTable VALUES(' .
  join(,,map($MyDatabase-quote($_),
  0, # REF
  0, # PARENT REF
  $FormData{'Title'} .   . $FormData{'Name'} . ,
  $FormData{'Email'} . ,
  \N,  # -- I REALLY WANT THIS TO BE A NULL VALUE!
  etc.,
  etc.,
  etc.
   )) .
 ')');

Which works fine except the \N isn't entered into my database as a null 
value. I've also tried '\N' and '' and .

Any ideas how I can solve this easily?

Thanks,


Jeff 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



RE: Help with database Design

2002-12-22 Thread Jeff Snoxell


 I'm designing a delivery program with php and mysql, and I'm
 having troubles with some tables, my problem is with the
 recipes, the recipes are divided into two tables one with a
 recipe id and description the other detailing the
 ingredients, of each particular recipe, that's where my
 problem starts because each ingredient is not unique and even
 it appears in many recipes, and another thing is every time
 and item is ordered their correspondent recipe ingredients
 are added , ie. pizza has a code 11, recipe has code 01 then
 all the ingredients in the recipe table have different
 ingredient code each, and are related by the recipe code 01,
 then each separate item must be counted, and added to the
 ingredients general daily totals, I mean pizza uses 2
 tomatoes then the general total will show two tomatoes and
 each other ingredient. There are also some combined recipes :
 Pizza with a special sauce, then this item has to query two
 parts of the same table, say code 12 is Pizza with a combined
 sauce of mushrooms and milk, and pineapples, so each
 ingredient must be added to the general total. I need help
 with the design because I don't want to have database anomalies.




 -Original Message-
 From: Ricardo Fitzgerald [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, December 22, 2002 11:22 AM
 To: [EMAIL PROTECTED]
 Subject: Help with database Design


create table recipes(
rid int not null primary key,
rname ) ;

create table ingredient(
iid int not null,
rid int not null,   # references recipe.rid
ridorder int not null,  # order of this ingredient in recipe
PRIMARY KEY(iid,rid,ridorder),
iname ...) ;


Your solution means a repetition of ingredients in the ingredients table. 
Then, if the unit cost of an ingredient changed you'd have to change every 
occurance of the ingredient... and where would you store info like the 
source manufacturer, tel and address etc etc. How about:

table meals(
m_id primary,
m_name, etc etc
)

table ingredients(
i_id primary,
i_name,
i_price, etc etc
)

table recipes(
r_id primary,
m_id,  #(the meal ident) referencess meals, there will be multiples of these
)

OR a really nasty way to do it with 2 tables..

table meals(
m_id primary,
m_name,
m_ingredients, # a comma separated list of ingredient ID's in a text field
)

table ingredients(
as above
)

so then you can read in a list of ingredient id's for each recipe, then 
'look up' the ingredients.


Jeff Snoxell
Aetherweb Ltd 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Programmatic MySQL backup in Perl

2002-12-20 Thread Jeff Snoxell
Hello,

I've successfully backed up my database to JeffsDB.sql using mysqldump with 
the -opt option.

When I try to restore it using: mysql -h myhost -u myusername -ppassword 
JeffsDB  JeffsDB.sql

I get:

ERROR 1065 at line 21: Query was empty

Now, line 21 of the SQL file contains:

/*!4 ALTER TABLE Dealers DISABLE KEYS */;

If I remove all the lines like the one above then something seems to happen 
but the process terminates moaning about some problem in my SQL 
statement... it points to a huge (1Mb ish) single line of values which were 
created by mysqldump and which, hence, _should_ be ok shouldn't they.

My questions:

1. Why should I have to remove those comments from the SQL shouldn't it 
just work?

2. Any ideas as to why, even with the comments removed, my SQL is reported 
as erroneous? Is it something to do with the very long single line and the 
fact that my mysql server is remote?

Many thanks, again!,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Best Windows MySQL client?

2002-12-20 Thread Jeff Snoxell
What's the best MySQL client for windows? I've tried 5 or 10 shareware ones 
that seem ok but all seem a bit chasty (some more than others). Any 
recommendations?

Thanks,

Jeff 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Restoring db from mysqldump output problem...

2002-12-20 Thread Jeff Snoxell
Hello,

I've successfully backed up my database to JeffsDB.sql using mysqldump with 
the -opt option.

When I try to restore it using: mysql -h myhost -u myusername -ppassword 
JeffsDB  JeffsDB.sql

I get:

ERROR 1065 at line 21: Query was empty

Now, line 21 of the SQL file contains:

/*!4 ALTER TABLE Dealers DISABLE KEYS */;

If I remove all the lines like the one above then something seems to happen 
but the process terminates moaning about some problem in my SQL 
statement... it points to a huge (1Mb ish) single line of values which were 
created by mysqldump and which, hence, _should_ be ok shouldn't they.

My questions:

1. Why should I have to remove those comments from the SQL shouldn't it 
just work?

2. Any ideas as to why, even with the comments removed, my SQL is reported 
as erroneous? Is it something to do with the very long single line and the 
fact that my mysql server is remote?

Many thanks, again!,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



CREATE TABLE issue?

2002-12-20 Thread Jeff Snoxell
Hi again :)

I found the following mysql stuff in the MySQL manual in a section 
explaining how to do relationships.

CREATE TABLE persons (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(60) NOT NULL,
PRIMARY KEY (id)
);

CREATE TABLE shirts (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
owner SMALLINT UNSIGNED NOT NULL REFERENCES persons,
PRIMARY KEY (id)
);

What's the point of the REFERENCES persons bit at the end of the 
definition of table Shirts? It doesn't seem to do anything.

Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



re: Accessing last_insert_id problem.

2002-12-19 Thread Jeff Snoxell


I'm working with MySQL 3.23.36 so, according to MySQL, Paul Dubois, New 
Riders running the query:

DELETE FROM my_table_name

should reset the auto-increment value... but it doesnt'.

What SQL do I use to reset the val.

You can't believe anything that book says.  The author didn't even include
anything about TRUNCATE TABLE my_table_name.


Nope. That doesn't do it either!

I go:

TRUNCATE TABLE my_table

then:

INSERT INTO my_table SET Name='Jeff'

then:

SELECT * FROM my_table

and lo-and-behold, the 'Ref' primary key auto-update field is 37062, not 1 
as I hoped.

I am managing to reset it to '1' by using a windows mysql client program 
but it doesn't show me what SQL it's executing in order to obtain the 
desired result.

Thanks,


Jeff



-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Accessing last_insert_id problem.

2002-12-19 Thread Jeff Snoxell
At 09:46 19/12/02 -0500, you wrote:

Jeff Snoxell wrote:


Nope. That doesn't do it either!

I go:

TRUNCATE TABLE my_table



Are you using InnoDB tables?  You'll have to do something akin to ALTER 
TABLE my_table AUTO_INCREMENT=1 ... at least according to Paul ... :)

No, I'm using MyISAM I believe.

Jeff

MySQL, query, SQL 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Programmatic MySQL backup in Perl

2002-12-19 Thread Jeff Snoxell
Hi,

is there an easy way to programmatically backup MySQL database tables using 
Perl? My Perl code will be running on a machine remote to the MySQL server.

Ta,

Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Accessing last_insert_id problem.

2002-12-18 Thread Jeff Snoxell
Hi,

I'm adding records to a db using the Perl DBI. Subsequent to adding a 
record I need to know the value of the auto-incrementing 'Ref' field so 
that I can place a copy of the relavent details into a log file.

I could query for the LAST_INSERT_ID but what if another process has 
added another record in the interim?

Is this a job for table locking?

Many thanks,

Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



re: Accessing last_insert_id problem.

2002-12-18 Thread Jeff Snoxell
Hi,

I've got that sussed now and am happily using the aquired ref to 
subsequently play with the record etc. One other related problem and I 
recon I'm sorted

How do I reset the auto-increment value?

I'm working with MySQL 3.23.36 so, according to MySQL, Paul Dubois, New 
Riders running the query:

DELETE FROM my_table_name

should reset it... but it doesnt'.

What SQL do I use to reset the val.

Ta,

Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



SELECT and UPDATE at the same time?

2002-12-18 Thread Jeff Snoxell
Hello again,

I'm selecting a group of records from my database. I then loop through the 
selected records and do some work based on what I find. But what I also 
want to do as I interrogate each record is update some of its fields with 
new values... but won't that screw up the outer loop? I mean if I try to 
execute a query whilst looping around the result set of a former query will 
I not screw up my result set that I'm looping through?

Also, is it possible to update specific fields of certain records within a 
SELECT query? ie can I do something like this:

SELECT * FROM my_table WHERE Age  50 AND UPDATE Status = OLD

Ta,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Re: SELECT and UPDATE at the same time?

2002-12-18 Thread Jeff Snoxell



SELECT * FROM my_table WHERE Age  50 AND UPDATE Status = OLD


No. That's goofy anyway.  Why wouldn't you just use a regular
UPDATE query?

UPDATE mytable Status = OLD WHERE Age  50;


Cos I want to do a fairly long-winded process on the records of those who 
are Age50 and subsequently update all of their records with the Date/Time 
that the change took place.

If I do the long-winded process and _then_ do the UPDATE query as you 
suggest I'm bound to update records which have been added in the meantime 
(by other clients, it's a busy database) which I've not yet processed.

I could make a list of all primary key values I've processed and then 
update them... or something equally ugly. I just figured there'd be a 
cleaner way to do it.

I really want to avoid grabbing all the results as my server is not located 
on my local machine.

Oh, I could update all the records where age50 with a known date/time then 
do my select query to select only those records with that time-stamp, and 
then do my long-winded processing.

Can't help thinking there must be a nicer way to do it.

Thanks,

Jeff 


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



How to enter data in MySQLCC

2002-12-12 Thread Jeff Snoxell
Hi,

I've installed MySQLCC as a client on Windows 2000, it connects via the net 
to a linux server running the mysql server and it's working ok to the point 
where I try to enter data into any cell of my tables other than one 
expecting a numerical value. I know MySQLCC is only in beta test mode but 
surely it should be able to accept data entry in non numerical cells?

Thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Inconsistent behavior when populating table?

2002-12-12 Thread Jeff Snoxell
Hi,

I've written a Perl script to populate my MySQL table. It grabs values from 
my old database and uses the following for each to form a comma separated 
list of single quoted items...

Each of the @values items is passed through: $value = 
$db-quote($original_value) first.

$st = $db-prepare('INSERT INTO Enquiries VALUES (' . join(,,@values) . 
')'  )
|| print 'could not prepare: ' . $db-errstr;

$st-execute() || print Couldn't execute statement:  . $st-errstr;

This works fine for _most_ of the fields but strangely, entire columns are 
incorrect sometimes. Especially where I'm sending UCT (10-digit unsigned 
ints) values to an unsigned int field. These work OK for some of my 
coulmns/fields but not for others.

Any clues as to what I'm doing wrong?

Many thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



More locking issues

2002-12-12 Thread Jeff Snoxell
Hi,

I'm new to MySQL. I see you all talking about locking databases etc... but 
isn't that the point of having a database server? So you don't have to 
worry about record locks?

I'm designing the backend for a popular site where a user's visit will 
result in multiple read/write operations on a database. Is record locking 
something I definitely need to do?

Thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Joined Tables Newbie Question

2002-12-11 Thread Jeff Snoxell
Hi,

I've worked with a database system in the past that allows you to setup 
permanent joins between two tables in a database such that if you select 
record 1 say on a parent table and then add records to a child table, the 
child table automatically knows that this record is a sub-record of record 
1 in the parent. Thus I can have databases with table structures like:

Customers: Orders: OrderedItems

Without having to always execute complex SQL queries every time.

Can I do anything with MySQL to make it act in the same way?

Many thanks,


Jeff


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php