Re: Last row in table

2002-10-31 Thread Aamer Rauf
In my perl script I do the following: my $sth = $dbh->prepare("SELECT MAX(Id) FROM sometable"); my $id = $sth->execute(); print "id: $id\n"; It prints 1 which I guess is the number of rows selected. I was expecting that it would give me the highest id in that table. How can I get that? Thanks for

Last row in table

2002-10-30 Thread Aamer Rauf
I have a mysql database. Lets say it has a table called "maintable" with primary key as main_id. I want to add other tables to the database and use main_id as foriegn keys in those tables. If I want to start with the last row of the maintable how can I using a perl script get main_id from the la

Jon Frisby---MySQL help needed

2002-07-29 Thread Aamer Rauf
Hi Jon, Whatever you have suggested so far hasn't worked. I thought that maybe something is missing in my stating the problem and implementing your suggested solutions. So here is a more expanded picture of the queries: $sth=$dbh->prepare("INSERT INTO TABLE1 (id,var1,var2) VALUES (?,?,?)"); $sth

Primary and Foreign Keys in MySQL

2002-07-24 Thread Aamer Rauf
Hello, I am working on MySQL database. I have come across a 'problem' but don't know how to get around that. The problem is the following: I have a table, say TABLE1, with primary key being called as table1_id. Now there are other tables, like TABLE1A, TABLE1B, TABLE1C etc.. where I want to us