Re: How to connect to mySQL?

2006-04-17 Thread Peter Brawley
徐晶 wrote: Hi, I want to know how I can connect to MySQL with ODBC driver? Is there something else to be installed besides MySQL for Windows? http://dev.mysql.com/doc/refman/5.1/en/odbc-connector.html PB Thanks a lot! Best Wishes, -- John Xu, EE, BUPT, P.R. China 北

Re: My Left Joins are Doubling the SUM()

2006-04-18 Thread Peter Brawley
mysql, My Left Joins are Doubling the SUM() SELECT packageItemID, packageItemName,packageItemPrice ,SUM(packageItemTaxAmount) as packageItemTaxAmount ,SUM(packageCreditAmount) as packageCreditAmount FROM packageItem LEFT JOIN packageCredit ON packageItemID=packageCreditItemID LEFT JOIN packageIte

Re: My Left Joins are Doubling the SUM()

2006-04-18 Thread Peter Brawley
mysql, Add a grouping clause to that query, ie SELECT packageItemID, SUM(packageItemPrice), ( SELECT SUM(c.packageCreditAmount) FROM packageCredit c WHERE c.packageCreditItemID = packageItemID ) AS CreditSum, ( SELECT SUM(t.packageItemTaxAmount) FROM packageItemTax t WHERE t.pac

Re: select records not in a *particular* many-to-many relationship

2006-04-18 Thread Peter Brawley
Marco, I've checked the archives and found an explanation as to how the check if a record is not in a many-to-many table. The answer to that is somewhat simple and clear to me. But here's my problem: how do you check if a record doesn't have a *particular* many-to-many relationship? As in,

Re: where group and inner join

2006-04-20 Thread Peter Brawley
Peter, Best groupmember, I am doing this query that works fine. SELECT tps.tour_player_id, sum(if(tsh.hole_number<=9, tps.strokes, '0')) AS 'front_9', sum(if(tsh.hole_number>=10, tps.strokes, '0')) AS 'back_9', sum(tps.strokes) AS 'score' FROM tour_player_score tps INNER JOI

Re: Form value editing

2006-04-20 Thread Peter Brawley
Brian E Boothe wrote: can someone please just send me or post a example of editing feilds of a mysql database within an html form and then updating the values thanks alot Google for php,mysql,examples. PB -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7

Re: WHERE doesn't work

2006-04-22 Thread Peter Brawley
Tom, > UPDATE command is not working for only the record that I want, but for >all in the table. I sees WHERE is not interpretated by Mysql server. At >least the result is identic to it. For example, If my php execute > UPDATE clientes SET tipo='r', nome_fantasia='cc', estado='24' >W

Re: WHERE doesn't work

2006-04-23 Thread Peter Brawley
Tom, Maybe a comunication trouble... Let me confirm. Are you saying that http://www.spalha.com.br/spalha/DB_code.html http://www.spalha.com.br/spalha/insert_client_code.html are not the code Im having troubles? As the code Im having trouble were some secret or so? if ($yes){ $communicat

Re: totalizing of Rows please help!!

2006-04-24 Thread Peter Brawley
Brian, i have three Values in each row of my MySQL database, im needing to sum them in the table as they are displayed per Row ?? how do i do this ? Projectname Elecremain Controlremain otherremain Project1 2300 1600 25

Re: If exists query.

2006-04-24 Thread Peter Brawley
Paul, >> > > I am doing queries that produce a table that looks something like this: >> > > >> > > Count   | IP Address    | First Seen    | Last Seen | Days >> > > 5000  10.0.0.1   2005-12-10    2006-04-15  50* >> > > 6500  10.0.0.2   2006-04-01    2006-04-06  

Re: totalizing of Rows please help!!

2006-04-24 Thread Peter Brawley
Brian E Boothe wrote: i have three Values in each row of my MySQL database, im needing to sum them in the table as they are displayed per Row ?? how do i do this ? As Eugene said, VARCHAR values don't sum, since they are not numeric. Either cast the column values you wish sums of to a numeri

Re: Stumped again by joins

2006-04-25 Thread Peter Brawley
Chris, >select count(distinct uid) as c >from aptg_guides_restricted as r, aptg_guides as g .. See the extensive notes on comma and SQL2003 joins at http://dev.mysql.com/doc/refman/5.1/en/join.html. Lose the comma join, make it a SQL2003 (explicit inner) join. PB - At 15:56 +0200 25

Re: Accumilating Blog Comments

2006-04-25 Thread Peter Brawley
-Patrick wrote: $query_rsComments = sprintf("SELECT id_com WHERE idart_com=%s ORDER BY date_com ASC", $KTColParam1_rsComments); No FROM clause. Also, don't you need single quotes around %s? PB - can anyone see what Im trying to do here? basically, I want to match the id_com with an id

Re: Calculate LONG/LAT from ZIP+4 (positve vs. negative longitude)

2006-04-25 Thread Peter Brawley
Daevid Vincent wrote: My confusion is that I have some formulas to plug in these values, but it seems to me that if I use the wrong set of data, my zipcodes will be wrong too. I also don't understand why there is even such a difference. I can understand a few decimal points being different,

Re: How to select the last entry per item

2006-04-27 Thread Peter Brawley
Brian Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question.  Apologies in advance if this is an old question. We are designing a simple a tracking database with a table of entries showing the current location of each it

Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
(0.01 sec) PB - Shawn Green wrote: --- Peter Brawley <[EMAIL PROTECTED]> wrote: Brian Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question. Apologies in advance if th

Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
LOL, three late nights in a row, lose that last post o' mine. PB - Shawn Green wrote: --- Peter Brawley <[EMAIL PROTECTED]> wrote: Brian Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to po

Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
FROM (   SELECT 'o1' AS TableName,customerid,shipcity,latest FROM o1   UNION ALL   SELECT 'o2' as TableName,customerid,shipcity,latest FROM o2 ) AS tmp GROUP BY customerid, shipcity,latest HAVING COUNT(*) = 1; PB - Peter Brawley wrote: LOL, three late nights in a row, lo

Re: Finding duplicates, etc.

2006-05-01 Thread Peter Brawley
Dirk, I would like to know where there ar duplicate accounts that do not have duplicate addresses. I think that at this point in time that these are included in the first query. I would like to separate these out to report on them. How about ... select account,ident,address from group15034_i

Re: sorting with php/mysql

2006-05-02 Thread Peter Brawley
Ross, This is my database. Nope, it's a table, not a database. ..I will use the item_id for the order but what if I want to change item_id 3 to item id 1? A primary key shouldn't be edited, and the literal value of an auto_increment column oughtn't to be relevant. If you really need a settabl

Re: Missing information Search

2006-05-03 Thread Peter Brawley
Robert >What I need to be able to do is find any values of K_Code in table 1 that don't >appear in table 2. SELECT t1.k_code FROM table1 t1 LEFT JOIN table2 t2 USING (k_code) WHERE t2.k_code IS NULL; PB - Robert Gehrig wrote: Hi I have two tables that are structured like so: Table 1:

Re: How to rename a DB

2006-05-05 Thread Peter Brawley
Hardi Have a look at "Rename Database" at http://www.artfulsoftware.com/queries.php#16 PB Hardi OK wrote: Hi, Anybody know how can i safely and easily rename a database in MySQL 5.0.19. Have tried some tips from google results (most of them are for MySQL 4.x) but no luck till now

Re: [Fwd: Getting next birthdays]

2006-05-08 Thread Peter Brawley
> I need the birthdays from yesterday, today and the next 4 or 5 birthdays. You don;t need to manually compute every date component. Try something like ... SELECT ... WHERE DATE_SUB(NOW(),INTERVAL 1 DAY) <= mem.birthday AND DATE_ADD(NOW(),INTERVAL 5 DAY) >= mem.birthday ORDER BY mem.bir

Re: Case confusion

2006-05-09 Thread Peter Brawley
Marcus, I just noticed that a key field (emailaddress) in my db is case sensitive when it should not have been, so now I've got a bunch of what are effectively duplicate records. I'm having trouble picking them out so I can manually merge/delete them before changing the collation on the field

Re: comparing postgis with mysql

2006-05-09 Thread Peter Brawley
Parang Saraf wrote: hello, I am relatively new in this field. I am designing a database to store the events extracted from the oceans. This project later demands of publishing data on web. I am not able to decide which database to use. Mysql with spatial extension or the postgis

Re: Reporting child tables referencing a parnet table

2006-05-10 Thread Peter Brawley
Ben,: Dear MySQL, Can you please tell me if there is a way of listing all child tables which have a foreign key reference to a parent? Find children of db.table: SELECT c.table_schema,u.table_name,u.column_name,u.referenced_column_name FROM information_schema.table_constraints AS c INNER JOI

Re: SQL:2003 standard

2006-05-10 Thread Peter Brawley
Peng Yi-fan wrote: Hi, It seems that ISO do not support SQL:2003 standard for free but I really need a copy. Does anyone know where I can download it? Or does anyone have it? Any type will be just OK. There is a 2002 draft at http://xml.coverpages.org/SQLX-5wd-14-xml-2002-08.pdf. PB

Re: Reporting child tables referencing a parnet table

2006-05-10 Thread Peter Brawley
ur 'db' and 'table' values. PB - mysql> SELECT version(); +-+ | version() | +-+ | 5.1.6-alpha-log | +-+ But thanks, I think I can work with this and get the information I want. Regards, Ben. Peter Brawley wrot

Re: Reporting child tables referencing a parnet table

2006-05-11 Thread Peter Brawley
rsively in an sproc. PB Regards, Ben Peter Brawley wrote: Ben Clewett wrote: Unfortunately I get: mysql> SELECT -> c.table_schema,u.table_name,u.column_name,u.referenced_column_name -> FROM information_schema.table_constraints AS c -> INNER JOIN information_schema

Re: PRINT statement?

2006-05-11 Thread Peter Brawley
Stephen Cook wrote: I appreciate it but SELECT isn't quite what I want. It adds an extra 4 to 6 lines to the output (drawing the table, headers, row counts, etc). PRINT simply outputs whatever comes after it: PRINT is not a SQL command. The mysql client (fortunately) does not speak Basic. T

Re: PRINT statement?

2006-05-12 Thread Peter Brawley
--silent option, thanks! Peter Brawley wrote: Stephen Cook wrote: I appreciate it but SELECT isn't quite what I want. It adds an extra 4 to 6 lines to the output (drawing the table, headers, row counts, etc). PRINT simply outputs whatever comes after it: PRINT is not a SQL command. The

Re: Need help with procedure

2006-05-15 Thread Peter Brawley
Barry wrote: Hello everyone! I have a table with saved clicks by users. Now i want to draw a graph with a php extension. Problem is: if i let me show the clicks, one day is missing. Because on that day noone clicked on the link. I use this query: SELECT DATE(c_clicktime) AS clicktime, count(c_id

Re: Need help with triggers

2006-05-15 Thread Peter Brawley
Daevid, >> > > This is my first trigger I'm trying to write. >> > > I have two tables. 'stores' and 'zipcodes'. >> > > I want to automatically set the latitude and longitude of the store using >> > > it's zipcode lookup in the zipcode table. >> > > DELIMITER $$; >> > > DROP TRIGGER `store_coo

Re: Baffled by error

2006-05-16 Thread Peter Brawley
Mike Blezien wrote: Hello, MySQL 4.1.12 trying to figure out why I keep getting this error with the following query: SELECT c.account_id,a.name,a.company,SUM(c.agent_product_time) AS mins FROM account a LEFT JOIN calls c ON c.account_id = a.id WHERE c.calldate >= DATE_SUB(NOW(),INTERVAL 14

Re: Baffled by error

2006-05-16 Thread Peter Brawley
DAY) AND c.agent_id = 9 GROUP BY a.account_id HAVING SUM(c.agent_product_time) >= 500 ORDER BY mins; PB - Mike Blezien wrote: Peter, - Original Message - From: "Peter Brawley" <[EMAIL PROTECTED]> To: "Mike Blezien" <[EMAIL PROTECTED]> Cc: "

Re: duration query: how to ?

2006-05-18 Thread Peter Brawley
Bob >I'd like to retrieve the total amount of time the articles have been in the >site from 2005-01-01 to 2005-01-31 and divide them by 365 (or 366 if leap >year). In a valid-time app like yours, it is usually more sound to mark "current" with a far-in-the-future date than with NULL. Arguably

Re: Recursive query

2006-05-18 Thread Peter Brawley
Peter, >Right now I am doing this with PHP and a recursive function, but is it >possible to do this directly with one query? SQL is not recursive, so you need an sproc. There are some examples with discussion at http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. PB - Pe

Re: Find invalid email formats using MySQL query.

2006-05-20 Thread Peter Brawley
Yesmin Patwary wrote: Dear All, My contact table has email field which contains many invalid email addresses. I find them using following php function. Is there a way to do that check in MySQL query? function emailValidate ($str) { $reg = "^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+

Re: LEFT JOIN Multiple Tables

2006-05-22 Thread Peter Brawley
Scott >SELECT * >FROM UserInfo u, DslInfo d >LEFT JOIN DslExtra e ON d.DslID = e.DslID >LEFT JOIN ExtraAddr a ON a.UserID = u.UserID >WHERE u.UserID = d.UserID; >However it appears this syntax is not valid in MySQL 5.x Right, as the 5.x docs say, 5.x wants ISO-compatible explicit joins, ie SEL

Re: LEFT JOIN Multiple Tables

2006-05-22 Thread Peter Brawley
man/5.1/en/join.html). PB - Scott Peter Brawley wrote: Scott SELECT * >FROM UserInfo u, DslInfo d LEFT JOIN DslExtra e ON d.DslID = e.DslID LEFT JOIN ExtraAddr a ON a.UserID = u.UserID WHERE u.UserID = d.UserID;

Re: I think I need a join

2006-05-23 Thread Peter Brawley
Critters wrote: >I can get it to join on either countryA or countryB but not both :| SELECT d.id, d.day, c1.country, c1.id, c2.country, c2.id FROM days d INNER JOIN countries c1 ON d.countryA = c1.id INNER JOIN countries c2 ON d.countryB = c2.id ORDER BY d.id (Getting ready for the World Cup

Re: Noob: Converting to Inner Join

2006-05-24 Thread Peter Brawley
>Are there any advantages to converting this 'working' query below to >use INNER JOIN ? >If so, what would the correct syntax be ? > >SELECT category.name, page.name, content.title, content.body >FROM category, page, content >WHERE content.page_id = page.id >AND page.category_id = category.id >AND

Re: Noob: Converting to Inner Join

2006-05-24 Thread Peter Brawley
, content.body FROM category, page, content WHERE content.page_id = page.id AND page.category_id = category.id AND category.id =1 ORDER BY content.order_id ASC LIMIT 0 , 30 And at 11:52 -0500 24/5/06, Peter Brawley wrote: Explicit INNER JOINs are easier to read, easier to debug, and since 5.0.12 alwa

Re: Fun with Dates and Incentives.

2006-05-24 Thread Peter Brawley
Brian Re your schema,   --it's redundant to define PRIMARY and UNIQUE keys on the same column,   --why not an INT student id?   --what if two (eg married) students share an email account?   --comparing datetimes across multiple time zones will be simpler if you       set completed_modules.tim

Re: Fun with Dates and Incentives.

2006-05-24 Thread Peter Brawley
Brian, Somehow the server ate my response... Re your schema, --it's redundant to define PRIMARY and UNIQUE keys on the same column, --why not an INT student id? --what if two (eg married) students share an email account? --comparing datetimes across multiple time zones will be simpler if you

Re: Fun with Dates and Incentives.

2006-05-24 Thread Peter Brawley
name, password, session id’s etc.) but I do get what you are saying. Thanks for the UTC_TIMESTAMP suggestion. Although, since I haven’t had a lot of experience, I don’t really understand why it is better than CURRENT_TIMESTAMP. But… that’s why I asked for advice J   -Brian   From: Peter Br

Re: Fun with Dates and Incentives.

2006-05-25 Thread Peter Brawley
ly imagine how that works, but if it does that solves huge problems for me and I seriously owe you! I'm gonna do some more research so I understand how this works. THANKS! -Brian _ From: Peter Brawley [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 24, 2006 3:56 PM To: Bria

Re: Joining multiple tables with grouping functions

2006-05-26 Thread Peter Brawley
Ville, >SELECT Invoices.*, SUM(InvoiceContents.Amount * InvoiceContents.Price) >AS InvoiceTotal, Customers.Name, SUM(Payments.Amount) PaidTotal, >MAX(Payments.Date) LastPayment FROM Invoices LEFT JOIN InvoiceContents >ON (InvoiceContents.InvoiceID = Invoices.ID) LEFT JOIN Customers ON >(Customers

Re: where more than 2 column not in a table

2006-05-29 Thread Peter Brawley
[EMAIL PROTECTED] wrote: Sory if my question makes you confused I've a problem with my sintax, I don't know how to select a list, whether it's not registered in another table, but it have 2 IDs. Not enough info. Show the Create Table statements, a bit of data, and the desired result. PB I

Re: ugly SQL for a report...

2006-05-29 Thread Peter Brawley
Cory, One way to lose the duplicate queries is to assign the count per pnr.id to a user var, and calculate via that value: SELECT pnr.ID AS ID_pnr, pnr.reservationdatetime, pnr.conf_number, pnr.created_by, ( SELECT @pp_cnt := COUNT(1) FROM pnr_passengers pp WHERE pp.ID_pnr = pnr.ID

Re: Need help querying a database of polynomials

2006-05-31 Thread Peter Brawley
Lew, >If I have another polynomial, say the sum of terms 1,3,4, and 5, how can I quickly search this >database to see if it's already been stored? SELECT DISTINCT polynomial_id FROM polynomial p1 INNER JOIN polynomial p2 ON p1.term_id=1 AND p2.term_id=3 INNER JOIN polynomial p3 ON p2.term_id=3

Re: where more than 2 column not in a table

2006-05-31 Thread Peter Brawley
(20) NOT NULL default '0', `name_club` varchar(20) NOT NULL default '', `time_update` datetime default '-00-00 00:00:00', PRIMARY KEY (`id_match`,`id_member`,`name_club`) ); I want to select a list, where it was registered in tbl club_get_match with Id- M

Re: Help with query: Row number / Rank from a query...

2006-06-01 Thread Peter Brawley
Dan, >I want to get a particular users 'rank' or row number from the query. SELECT 1+COUNT(*) AS Rank FROM results r1 INNER JOIN results r2 ON r1.points I have a regular query lets say: SELECT user, points FROM results ORDER BY points DESC so I get: userpoints --- john23 s

Re: help on SQL JOIN

2006-06-02 Thread Peter Brawley
Nhadie, ...what i want to actually achieve is to get only the time of the first INVITE and then it's corresponding BYE so it should look like this +--+--+--+--+--+--+ | username | t1method | t2method | start| stop | timediff | +-

Re: hierarchical sql

2006-06-05 Thread Peter Brawley
João Cândido de Souza Neto wrote: Hi everyone, Someone know if mysql 5 has hierarchical sql? http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html PB Thanks. -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 26

Re: Joins - Multiple rows from a single table

2006-06-07 Thread Peter Brawley
Geoffrey, >SELECT > bugs.id, bugs.assignee, users.username, bugs.submitter >FROM fb_bugs AS bugs, >fb_users AS users >WHERE users.id = bugs.assignee >My problem is that I also want the users.username for bugs.submitter. How can I do that? Join users a second time for bugs.submitter, eg ...

Re: functions in AS

2006-06-07 Thread Peter Brawley
Jay, We all know that you cannot do something like this; sum(if(substring(updated, 1, 10) = curdate(), 1, 0)) AS curdate() nor can you use user variables even though they get set properly set @d1 = curdate(); sum(if(substring(updated, 1, 10) = curdate(), 1, 0)) AS @d1 So, does anyone know of a w

Re: functions in AS

2006-06-07 Thread Peter Brawley
Jay, [snip] We all know that you cannot do something like this; sum(if(substring(updated, 1, 10) = curdate(), 1, 0)) AS curdate() nor can you use user variables even though they get set properly set @d1 = curdate(); sum(if(substring(updated, 1, 10) = curdate(), 1, 0)) AS @d1 So, do

Re: MS access query in mysql

2006-06-13 Thread Peter Brawley
Andrew Zahn wrote: I am using MS Access to read from a MySQL database. The query generated through access listed below returns incorrect data when executed in Access and doesn't work at all in MySQL. I believe it has to Last() and with the # symbols around the date. Any insight into this probl

Re: error in copy data from mysql 4.1 to mysql 5.0 server

2006-06-19 Thread Peter Brawley
prathima rao wrote: hello every one, i have two mysql servers one is the local server 4.1 and one is the centralised server 5.0 . i copy data from 4.1 to 5.0 through a option called copy database to another server/host - (drop table if exists) during this process i am not getting the same resu

Re: error in copy data from mysql 4.1 to mysql 5.0 server

2006-06-19 Thread Peter Brawley
erver, as the manual recommends for major upgrades? PB rao - Original Message - From: "Peter Brawley" <[EMAIL PROTECTED]> To: "prathima rao" <[EMAIL PROTECTED]> Cc: Sent: Monday, June 19, 2006 6:57 PM Subject: Re: error in copy data from mysql 4.1 to

Re: Find rows in table A where table B = 'hello' AND table B = 'world'

2006-06-19 Thread Peter Brawley
David, How do I find all the tags that are tagged with the words "mysql" AND "databases" AND "tutorial"? If there are no url-keyword dupes in tbl_url_keyword ... SELECT u.urlid, u.url FROM tbl_url_keyword AS uk INNER JOIN tbl_url AS u USING (urlid) INNER JOIN tbl_keywords AS k USING (keywordi

Re: Math problem

2006-06-22 Thread Peter Brawley
>It appears that mysys 4.1 does not know how to multiply a dollar >amount to another number. Has anyone else seen this problem? If price is a string beginning with '$', MySQL will autoconvert SubString(price,2) to a numeric iif it's in a numeric expression, but you'd be much better off losing t

Re: Exclusion Query

2006-06-22 Thread Peter Brawley
>SELECT * >FROM Customers C >LEFT OUTER JOIN Orders O >ON C.CustomerID = O.CustomerID >WHERE OrderID IS NULL OR C.CustomerID IS NULL >ORDER BY OrderID Correct except lose "OR c.customerID IS NULL", it makes no sense. PB - Daniel McQuay wrote: had a problem like this in class today

Re: Left Join Help

2006-06-23 Thread Peter Brawley
Paul, >SELECT ... >FROM > tourdates td, > tbl_ARTST as art, > artist_tourdate artd , > tbl_VENUES tv, > tbl_VENUE_CAPACITY tvc , > tbl_VENUE_AGE_XREF tvax, > tbl_VENUE_AGES tvage >LEFT JOIN tbl_VENUE_CAPACITY ON (tv.ID=tvc.VENUE_ID) >LEFT JOIN tbl_VENUE_AGE_XREF ON (tv.ID=tvax.VENUE_ID) >L

Re: selecting data from 2 local DBs with same table structure

2006-06-24 Thread Peter Brawley
>I need the query to select the data from table1 on db1 and then select the >data from table1 on db2 and return a result of where if a field data value >is found in both tables that matches on name for example, it would count the >occurrences. Not entirely clear. Do you mean ... SELECT  

Re: DELETE based on JOIN

2006-06-27 Thread Peter Brawley
Jesse wrote: I need to delete some records based on a JOIN relation. The following works in Microsoft SQL Server, and the syntax appears to be correct for MySQL, but it reports "syntax..near 'DELETE FROM ConvInvDet FROM ConvInvDet H...". What's the proper way to format this for MySQL? DELETE

Re: Tough query to crack

2006-06-28 Thread Peter Brawley
Steve, > INSERT INTO master_context_list (Context_ID, Target_ID) >SELECT Context_ID = @ContextID, targets_list.Target_ID FROM targets_list > WHERE Target_ID IN ( SELECT Target_ID FROM #APPLICABLE_TARGET_IDS ) [EMAIL PROTECTED] tells the server to return 1 when the column value of co

Re: Use of @ in Stored Procedure

2006-06-28 Thread Peter Brawley
Jesse wrote: I have skimmed through several pages of instructions on creating stored procedures, and I can't seem to find when I should and should not use the "@" symbol before a variable name? I have seen a lot of procedures where it's always used, and I've written a procedure or two that do

Re: Tough query to crack

2006-06-28 Thread Peter Brawley
nd any target ID found with the flags associated with context 3 applied. These flags are processed earlier in this same procedure and the IDs are put into the APPLICABLE_TARGET_IDS temporary table. steve--- Steven J Orton Software Engineer Northrop Grumman Mission Systems Middletown, RI

Re: Tough query to crack

2006-06-28 Thread Peter Brawley
he stored procedure thing and only a little better at SQL statements as a whole:) Steven J Orton Software Engineer Northrop Grumman Mission Systems Middletown, RI 02842 -Original Message- From: Peter Brawley [mailto:[EMAIL PROTECTED]] Sent: Wed 6/28/2006 4:57 PM To: Orton, Steve; mysql

Re: Distinct problem

2006-06-28 Thread Peter Brawley
Tanner >I am trying to group my results by the last activity on each row, my query >looks like this >select text, dt, item_id from table >where >group by item_id >order by dt DESC SELECT t1.item_id, t1.dt, t1.text FROM table AS t1 LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AN

Re: Distinct from two tables

2006-06-29 Thread Peter Brawley
Mark Steudel wrote: Is there a way get distinct results between pf and sf? Select pf.name, sf.name From tblpropertyfeatures, tblsuitefeatures Inner Join tblfeatures AS pf ON tblpropertyfeatures.featureid = pf.id Inner Join tblfeatures AS sf ON tblsuitefeatures.featureid = sf.id Do you m

Re: summing values

2006-06-30 Thread Peter Brawley
>Since one person can be listed in both 1 and 2 in each section (just not >in the same row) I need to sum up that person's votes between the two >columns.  I've tried summing two subqueries but it errors out because of >returning two values.  Unclear. Where is a user's 1 or 2 recorded? What i

Re: Need way to see all relations?

2006-06-30 Thread Peter Brawley
Daevid, I have a 'users' table. And there are all kinds of related tables like 'logs', 'preferences', etc. that all have a FK reference back to this user ID. I want to make a query or use some PHP to build a list of all tables in my DB that are references. Query to find tables with FK refere

Re: need one query

2006-07-01 Thread Peter Brawley
>orgunit    parent   value >12   10  x >15    12 y >16    12 z >17 

Re: Query multiple tables

2006-07-02 Thread Peter Brawley
>What query do I need to get >AccommodationName and what attractions it has from AccommodationAttractions SELECT ac.accommodationname, at.attractionname aa.AccomodationAttraction FROM accommodationattractions AS aa INNER JOIN accommodations AS ac USING (accommodationid) INNER JOIN attractio

Re: Comparison problem

2006-07-13 Thread Peter Brawley
Jean-Claude But how to list all AC in Chimeric_Cluster_IDs _ABSENT_ from the gene_length table, this one for instance : mysql> select Chr_Name, Unigene_ID from gene_length where Unigene_ID='Mm.371574'; Any idea ? That is called an exclusion join. To get at it, you need to adopt explicit joi

Re: Comparison problem

2006-07-13 Thread Peter Brawley
a separate query, save it to a temp table (excluding the rows with NULLs), and join 150genes to that. All this will perform much better if you can restructure the tables to permit equality comparisons rather than require LIKE comparisons, which are extremely slow. PB - Garaud

Re: Pivoting the result set.

2006-07-15 Thread Peter Brawley
Would like for the results to become pivoted and be transposed to look like this. There's a little step-by-step for this at http://www.artfulsoftware.com/queries.php under 'Pivot tables', 'Group column statistics in rows'. PB - Ow Mun Heng wrote: Hi, I have a query that comes out li

Re: arrays in stored procedures - pl. help

2006-07-25 Thread Peter Brawley
My question is how do I send multiple sets of data into a stored procedure without doing the things I had outlined. MySQL doesn't have arrays. Pass the data in a comma-delimited string and PREPARE the statement, or pass it as a temp memory table. PB - L P wrote: Chris, thank you fo

Re: Returning results as a field name

2006-07-26 Thread Peter Brawley
-+--+--+ | Mark | Yes | No | | Leigh | Yes | No | +---+--+--+ 2 rows in set (0.00 sec) Any clues to get the other questions and their answers into the table greatly appreciated. cheers Mark Dale *** -Or

Re: Returning results as a field name

2006-07-26 Thread Peter Brawley
Pardon me, too early & not enough coffee, that's not quite the 'max-concat trick', but it oughtta work. PB - Peter Brawley wrote: Mark, >Thanks for the start Peter. I have got that 'Pivot table using a JOIN' >query returning results for 2 re

Re: Checkboxes

2006-07-26 Thread Peter Brawley
Nicholas Vettese wrote: I am trying to allow a user to use checkboxes for multiple selections, and I am trying to get the database to record the choices made by the user. I am using a VARCHAR(250), but I am guessing that may be wrong. Also, other than adding a "[]" to the end of the 'name' (e

Re: JOIN table where not in other table

2006-07-26 Thread Peter Brawley
Peter >feels strange to JOIN tables and >choose rows where the join value is NULL (left outer join) :) It's standard SQL and has a name, "exclusion join". Not a bit more "strange" than counting wot's missing. PB Peter Lauri wrote: 4.0.27, so that is probably the reason. Any other way the

Re: Newbie

2006-07-27 Thread Peter Brawley
Naser, Md Abu wrote: Hi All, I am very new. I wish to do some exercise before I go to real business. Could anyone advise me any tutorial link or resources for beginner? Some tutorials are listed at http://www.artfulsoftware.com/dbresources.html. Also you might want to look at http://www.a

Re: Stored procedures

2006-07-30 Thread Peter Brawley
>I'm trying to make stored procedures use parameters for limit and tables, I >guess this is either me using the wrong datatype or it's not possible.  I'm >having the same issue with seting the table for the query: SET @sql = CONCAT( 'select * from some_table limit ', some_limit ); PREPARE s

Re: Finding the closest value

2006-07-31 Thread Peter Brawley
>Is there an efficient way to find the closest numerical value, across >three columns? I do not know if there is a way to find it across one. Not sure about efficiency, but if the criterion number is @n, do you mean ... SELECT LEAST( ABS(MIN(@n-col1)),   LEAST( ABS(MIN(@n-col2))

Re: logic/db question

2006-08-02 Thread Peter Brawley
Bruce, my question, how can i come up with a sql query that will list all the children (and children's children...) of a top level item? This is an edge list tree model, ID being the child node, parentID being the parent node, the row denoting the edge between ID and parentID. Unless you kno

Re: logic/db question

2006-08-02 Thread Peter Brawley
/actual url... -bruce -Original Message- From: Peter Brawley [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 02, 2006 2:15 PM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: Re: logic/db question Bruce, my question, how can i come up with a sql query that will

Re: Running Totals?

2006-08-02 Thread Peter Brawley
Barry >It would make life easier if I could also show a column >with the cumulative count for each month.  Set @cum - 0; Select   Monthname(DatePaid) Month,   Year(DatePaid) Year,   Count(*) as Registrations,   Extract(Year_Month from DatePaid) AS Monindex,   @cum := @cum + Count(*) AS

Re: Finding the closest value

2006-08-03 Thread Peter Brawley
AS min FROM tbl GROUP BY id; PB - Lee Goddard wrote: Peter Brawley wrote: />Is there an efficient way to find the closest numerical value, across >three columns? I do not know if there is a way to find it across one. / Not sure about efficiency, but if the criterion

Re: Tricky query

2006-08-04 Thread Peter Brawley
>Can this be expressed somewhat more elegantly than multiple EXISTS subqueries? >SELECT DISTINCT key FROM keyval outer >WHERE EXISTS (SELECT * FROM keyval inner >WHERE outer.key = inner.key >AND inner.val = 8) >AND EXISTS (SELECT * FROM keyval inner >WHERE outer.key = inner.key >

Re: Limiting a Join

2006-08-05 Thread Peter Brawley
Michael, >If I wanted all records from "a" and only the first record from "b", >how would I integrate a LIMIT statement in this, or some other >statement that would achieve the same end? Appending LIMIT >to the end of the query will limit the entire result set, which is not >the desired effect.

Re: Limiting a Join

2006-08-05 Thread Peter Brawley
I'm wondering if you have any thoughts on this approach. Best, Michael Peter Brawley wrote: Michael, >If I wanted all records from "a" and only the first record from "b", >how would I integrate a LIMIT statement in this, or some other >statement that would achieve t

Re: joining tables

2006-08-10 Thread Peter Brawley
Reinhart, >So even the clients who have no entry in events on that day, but they have >an event in that specific month and year should be shown with a 0 value. Try ...FROM clients LEFT JOIN events... PB - Reinhart Viane wrote: Table1: events Durationworkdateclientid

Re: How to create a table of dates?

2006-08-10 Thread Peter Brawley
>So if the date range is '2001-01-15' to '2003-04-01' then it would generate >approx 800 rows with dates between these 2 ranges. I can't seem to figure >out how to do it without writing a program. See Dates/'Make a calendar table at http://www.artfulsoftware.com/queries.php. PB - mos

Re: PHP script to simply manage tables

2006-08-11 Thread Peter Brawley
Thomas >Is there any PHP script to create it automatically (in the same way >phpMyAdmin does, but with less functionalities)? Mebbe theUsual will be helpful http://www.artfulsoftware.com/theusual.html, code at http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1_appe.html#theusual_php.

Re: Do I really need a subquery?

2006-08-13 Thread Peter Brawley
Geoffrey, >Do I really need that subquery? You need its scalar result just once, so why not ... SELECT url, @maxcount:=COUNT(1) FROM bi_bookmarks WHERE date > NOW() - INTERVAL 86400 SECOND GROUP BY url ORDER BY count DESC LIMIT 0, 1; SELECT title, url, COUNT(1) AS count, CEIL(COUNT(1) / (

Re: Audit trail

2006-08-21 Thread Peter Brawley
Chris >I would like to create an audit trail for one table in my DB.  Users will login to my >web site and be able to enter and edit information, I want to keep a record of what >changes are made by what user.  These users will be web site users and not actual >MySQL users.  Is there an eas

  1   2   3   4   5   6   7   8   9   >