RE: help optimizing log table deletes

2002-04-02 Thread Johnson, Gregert
You can use the LIMIT clause to break up a long DELETE into a series of shorter ones, executed in a loop. So, in pseudo-code: Set delete_row_max = 1000 (or another appropriate value) do { DELETE FROM outgoing WHERE timestamp last_time LIMIT delete_row_max; row_count = no. of

RE: fast,efficient query for counting

2002-03-20 Thread Johnson, Gregert
$dbh = DBI-connect(DBI:mysql:database=$database;host=$host,$user,$mysqlpassword,{'RaiseError'=1}); $update_number = UPDATE $table set total_clicked = total_clicked + 1; $sth = $dbh-prepare($update_number); if (!$sth) { die Error: . $dbh-errstr . \n; } if (!$sth-execute) { die Error: .

RE: Sub-select look-alike?

2002-03-13 Thread Johnson, Gregert
SELECT f.language as From, t.language as To FROM language f, language t, language_pairs lp WHERE f.id = lp.from AND t.id = lp.to; --Greg Johnson -Original Message- From: Andreas Frøsting [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 10:13 AM To: [EMAIL PROTECTED] Subject:

RE: Getting Data From One Table Based On Another - Agh!

2002-02-20 Thread Johnson, Gregert
SELECT Table1.orderid, Table2.otherfield1, Table2.otherfield2 FROM Table1, Table2 WHERE Table1.orderid = Table2.orderid; --Greg Johnson -Original Message- From: SpyProductions Support Team [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 12:31 PM To: [EMAIL PROTECTED]

RE: insert select in ONE statement?

2002-02-20 Thread Johnson, Gregert
SELECT LAST_INSERT_ID() will return the last auto_increment key written. This value is connection-specific, so that inserts performed on other connections will not affect it (in other words, you'll get the last key generated by user 1, regardless of what user 2 does in the meantime). --Greg

RE: Run a file from mysql prompt

2002-02-01 Thread Johnson, Gregert
cat thefilename | mysql -uuser -ppassword dbname --Greg Johnson -Original Message- From: David Turner [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 2:13 PM To: [EMAIL PROTECTED] Subject: Run a file from mysql prompt How do I get a file full of sql commands to run from

RE: MySQL and 3NF

2002-01-30 Thread Johnson, Gregert
Create two association tables: Contributor ++--+--+-+-++ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-++ | Contributor_ID | tinyint(3) | |

RE: unique problem?

2001-12-31 Thread Johnson, Gregert
SELECT REPLACE(DIRECTIONS, '#', 'No.') FROM shpr_rcvr WHERE etc. -- Greg Johnson -Original Message- From: Richard Reina [mailto:[EMAIL PROTECTED]] Sent: Monday, December 31, 2001 1:23 PM To: [EMAIL PROTECTED] Subject: unique problem? I have a table shpr_rcvr that stores info about

RE: Can this be done?

2001-12-07 Thread Johnson, Gregert
UPDATE myTable SET DueField = 0, StatusField = IF(StatusField = 'O', 'C', StatusField) WHERE PrimaryKeyField = XYZXYZ; -- Greg Johnson -Original Message- From: Chris Boget [mailto:[EMAIL PROTECTED]] Sent: Friday, December 07, 2001 1:42 PM To: [EMAIL PROTECTED] Subject: Can this be

RE: Help with aggregate query

2001-11-12 Thread Johnson, Gregert
SELECT SUM(d.AcctSessionTime) + IFNULL(m.Minutes, 0) FROM detail d LEFT OUTER JOIN monthly_usage m ON d.UserName = m.UserName WHERE d.UserName = 'foo'; Or, to summarize for all users: SELECT d.UserName as user, SUM(d.AcctSessionTime) + IFNULL(m.Minutes, 0) FROM detail d LEFT OUTER JOIN

RE: Beginner question - getting last inserted ID

2001-11-09 Thread Johnson, Gregert
If you are using the Mark Matthews JDBC driver (MM.MySQL), there's another way to get the last insert id: instead of using a generic Statement object to execute the INSERT command, use an org.gjt.mm.mysql.Statement object. After executing an INSERT, the method getLastInsertID() will return

RE: bad practice to have a primary key field whose value changes?

2001-10-30 Thread Johnson, Gregert
Use a join query, rather than separate single-table queries: SELECT a.*, n.url FROM articles a, news_sites n WHERE a.news_site_key = n.news_site_key; -- Greg Johnson -Original Message- From: Bennett Haselton [mailto:[EMAIL PROTECTED]]

RE: Left Join problem

2001-10-03 Thread Johnson, Gregert
It looks to me as though the tracked.window=137 condition is suppressing output of any available rows which do not have a target match in tracked - tracked.window would = NULL in those cases. --Greg Johnson -Original Message- From: George Eric R Contr

RE: Left Join problem

2001-10-03 Thread Johnson, Gregert
? -Original Message- From: Johnson, Gregert [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 10:03 AM To: [EMAIL PROTECTED] Subject: RE: Left Join problem It looks to me as though the tracked.window

RE: Help!

2001-09-18 Thread Johnson, Gregert
Mariacust must be included in you FROM list: SELECT ... FROM customers, mariacust WHERE ... -Original Message- From: Armando Cerna [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 18, 2001 12:16 PM To: [EMAIL

RE: Select where A is not a member of B

2001-09-10 Thread Johnson, Gregert
SELECT DISTINCT u.userid, IF( ul.listid, true, false) FROM user u LEFT OUTER JOIN userlist ul ON u.userid = ul.userid AND ul.listid = listid; -Original Message- From: David Otton [mailto:[EMAIL PROTECTED]]

RE: check if an index exists?

2001-08-17 Thread Johnson, Gregert
show index from tablename; This returns a result set listing all indexes on the table. --Greg Johnson -Original Message- From: Christopher Teli [mailto:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 12:32 PM To:

RE: Does not match

2001-06-22 Thread Johnson, Gregert
Try something like SELECT fid, Family_Last_Name, Phone, playertable.Family_ID FROM familytable LEFT OUTER JOIN playertable ON playertable.Family_ID = familytable.fid AND playertable.SportRegistered = 'O' GROUP BY fid ORDER BY Family_Last_Name ASC; The rows from

RE: SELECT question.

2001-05-30 Thread Johnson, Gregert
SELECT l.load_no, l.date FROM loads l LEFT OUTER JOIN invoiced i ON l.load_no = i.load_no WHERE l.dlvr_date 0 AND i.load_no IS NULL; -- Greg Johnson -Original Message- From: Richard Reina [mailto:[EMAIL PROTECTED]] Sent: Wednesday,

RE: LIMIT

2001-04-19 Thread Johnson, Gregert
SQL Server will allow you to limit a SELECT to the first n rows, but not (to my knowledge) to skip a number of rows before returning the desired rows. The mechanism used is SET ROWCOUNT (6.5 and 7.0) or TOP (7.0). The difference is that SET ROWCOUNT limits the output rows before applying an

RE: Mysql speed :)

2001-04-06 Thread Johnson, Gregert
What would really help would be to use multiple row inserts, i.e. INSERT INTO speed1 VALUES (a,b,c),(d,e,f),(g,h,I),... So, prepare a series of inserts, each with a few hundred (or even thousand) row value sets. --Greg Johnson -Original Message-

RE: table handler

2001-03-13 Thread Johnson, Gregert
The valid range for an 'int' data type (your "id" column) is -2147483648 to 2147483647. The value you are attempting to set (37647438380) is not within this range. --Greg Johnson -Original Message- From: Andreas Gietl [mailto:[EMAIL PROTECTED]]

RE: row-to-column-conversion in 1 query

2001-01-31 Thread Johnson, Gregert