Another permission question...

2003-09-17 Thread Tore Bostrup
MySQL 3.23.36 (yeah, I know it's getting old...): What permission do I need to run the following query: REVOKE ALL ON mydb.* FROM 'sdaf'@'%'; I get an error 1044: "Access denied for user: 'Admin@' to database 'mydb'" My user has GRANT permission on mydb (database) and GRANT permission on all

Revoke User's Global Privileges?

2003-09-17 Thread Tore Bostrup
How does one go about revoking a user's GLOBAL privileges with a REVOKE statement? TIA, Tore

HELP - Permission denied with ODBC 3.51 - not with tools...

2003-09-15 Thread Tore Bostrup
Why do I get a permission denied when I try to execute the following SQL statement via ODBC 3.51? UPDATE mysql.user SET Password = Password('Blank') WHERE user = 'sdaf' I can execute the statement from a tool such as SQLYog (logged in as 'myAdmin'). The error I get is: DIAG [S1000] [MySQ

GRANT and REVOKE issue...

2003-09-09 Thread Tore Bostrup
I seem to be having some trouble with using GRANT and REVOKE. I am implementing a "user management" form in my application that does the following: REVOKE ALL ON mydb.* FROM 'Username'@'%' I get an error "Access denied for user: 'MyAdmin@' to database 'mydb'". The Revoke statement is being exec

Re: HAVING vs. WHERE

2003-03-05 Thread Tore Bostrup
HAVING is for qualifying result rows based on the value of aggregate functions, WHERE is for qualifying result rows based on individual (column) values. So in you case you should use WHERE. Although useful in the right situation, HAVING is used much less than a WHERE clause. One example of how t

Re: Reshuffling unique integers

2003-03-04 Thread Tore Bostrup
Allow negative values in the column (but don't use them). When modifying the values, give them their correct numeric value but make them negative. Then update the negative values to positive. HTH, Tore. - Original Message - From: "Amittai Aviram" <[EMAIL PROTECTED]> To: "Mysql" <[EMAIL P

Re: Perplexed by reverse SELECT statement.

2003-03-04 Thread Tore Bostrup
I'm sure you are aware that this is a non-normalized database design, and that those tend to make designing queries more difficult and/or inefficient. The LIKE operator should give you what you want, but you need to be careful: (PHP string def:) $sSQL = "SELECT FROM WHERE readBy LIKE '$UserID,

Re: Duplicate

2003-03-02 Thread Tore Bostrup
Simply create a UNIQUE Index on the column to avoid duplicates. That will be case insensitive, and trailing spaces AFAIK, but spaces inside the columns text have significance. HTH, Tore. - Original Message - From: "Dee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, March 02,

Re: update question

2003-03-02 Thread Tore Bostrup
iginal Message - From: "chip wiegand" <[EMAIL PROTECTED]> To: "Tore Bostrup" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, March 02, 2003 4:25 PM Subject: Re: update question > On Sun, 2 Mar 2003 02:06:40 -0500 > "Tore Bostrup"

Re: Using SUM in a select statement.

2003-03-02 Thread Tore Bostrup
What you are looking for appears to be report layout. Keep in mind that SQL will only return multiple rows, all with the same columns populated. To even get close to what you want, you can create a query that returns: TeamOwner, Player, Position, Goals, Points And then your application can mass

Re: update question

2003-03-01 Thread Tore Bostrup
I assume you are storing your dates in a char/varchar column - not a good choice to start with... :-< Assuming all the values are supposed to be stored as MM-DD-YY (anothoer marginal choice, but the problem may not rear its head again for another 96+ years), you can do the following: UPDATE mytab

Re: SELECT DISTINCT question

2003-02-28 Thread Tore Bostrup
Your guess is correct, DISTINCT works on the result set - i.e. if the result set contains two result rows that contain exactly the same values, it will eliminate the duplicate from the result set. SELECT DISTINCT is equivalent with using a GROUP BY without an aggregate function. SELECT DISTINCT x

Re: mysql: change column to row

2003-02-28 Thread Tore Bostrup
The technique to do this is called a cross-tab(ulation) query or a pivot table. A simple (and pretty static) cross-tab query can be created by the use of CASE WHEN. But if you want a more generic solution that works for all values, it gets a bit more complex. Spend some time investigating Google

Re: query or php with a join

2003-02-28 Thread Tore Bostrup
Since you haven't told us your table designs, I have to guess, but something like: SELECT I.ItemSKU, I.ItemName, I.ItemDescription, I.PostCode, I.Category, I.CityID, I.CTelephone, I.ItemID, I.Cfax, I.Cemail, I.Caddress

Re: SELECT DISTINCT question

2003-02-28 Thread Tore Bostrup
at an INNER JOIN differently from a join in the WHERE clause - I don't know how the MySQL optimizer works. Regards, Tore. - Original Message - From: "Sheryl Canter" <[EMAIL PROTECTED]> To: "Tore Bostrup" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sen

Re: SELECT DISTINCT question

2003-02-27 Thread Tore Bostrup
DISTINCT works on the result set and across the entire select list. It will suppress duplicate result *rows*. This is an interesting problem when using MySQL due to the lack of support for nested SELECTs. In other database systems, I'd use a correlated subquery in the where clause, but with MySQ

Re: Inner join question!

2003-02-27 Thread Tore Bostrup
The only reason I could see for this would be if you have duplicates (across date num1 num2 time) in both tables, or quadruplicates in one. You join looks correct, so take a closer look at your data. Try running the following queries: SELECT A.date, num1, num2, A.time, Count(*) FROM A GROUP BY A

Re: I'm not sure if this is HTML question or PHP...

2003-02-27 Thread Tore Bostrup
The technique you are looking for is usually referred to as "recordset paging". A Google search for PHP Recordset Paging brought back a slew of hits. Find one that appeals to you/explains what it does so you can use it. HTH, Tore. - Original Message - From: "Stitchin'" <[EMAIL PROTECTE

Re: Random 32bit number for columns?

2003-02-26 Thread Tore Bostrup
I assume the RAND() function can be used in in an insert: INSERT INTO target (MyRandVal, OtherColumns) VALUES (RAND() * (MaxVal - MinVal) + MinVal, OtherData) OR INSERT INTO target (MyRandVal, OtherColumns) SELECT RAND() * (MaxVal - MinVal) + MinVal, OtherData FROM ... HTH, Tore.

Re: Column Type help

2003-02-26 Thread Tore Bostrup
The only two considerations I can think of to choose one type of TEXT column over another would be: 1: The added storage required by a LONGTEXT over a TINYTEXT is only 3 bytes per row. Compared to the anticipated average size of the data, this would be neglibible. 2: If you want to impose somewha

Re: Help needed with SQL...

2003-02-26 Thread Tore Bostrup
It is usually called a self-join, and it is a very useful technique. You have to do this when you need to obtain or access two separate subsets from a single table and somehow use those in a join. In this case, you want the groupids a specific member belongs to (set one) as well as all members be

Re: index questions

2003-02-26 Thread Tore Bostrup
sword: You at least *document* the *intent* that way, but if anyone sees the declaration and expects it to do something, they could be in for a surprise. Regards, Tore. - Original Message - From: "Sheryl Canter" <[EMAIL PROTECTED]> To: "Tore Bostrup" <

Re: index questions

2003-02-25 Thread Tore Bostrup
If my answers are too basic, please accept my apology. 1: There is no difference: KEY is a synonym for INDEX. 2: In a syntax description, the use of [square] brackets means that the part in brackets is optional. Whether you include it or not doesn't change the semantics. 3: The PRIMARY KEY is

Re: Reference to a downloadable file

2003-02-25 Thread Tore Bostrup
How do you serve up the other data from the database? Are the ZIP files in a directory that is accessible from the web? In the simple case, all you need to do is create an Download Design construct in your output from the php script. So if the column returned from the MySQL query is called ZIPFi

Re: Problem with MySQL, MyODBC, Access 2002 and Japanese.

2003-02-25 Thread Tore Bostrup
Don't know, but: Are you using the Japanese Access 2002? What locale is your OS configured for? HTH, Tore. - Original Message - From: "Juan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 25, 2003 6:12 AM Subject: Problem with MySQL, MyODBC, Access 2002 and Japanes

Re: mysql:Question about definition and index for performance

2003-02-25 Thread Tore Bostrup
alter table tableA add index(key1, acct) creates a single index across the two columns. Trying to visualize the index as a sorted list (of course it is a b-tree), it will look something like: (key, acct:) 1,1 1,2 1,3 1,5 1,8 2,1 2,4 2,5 2,6 3,2 3,9 ... etc. Therefore, this index is not very use

Re: Select based on related date

2003-02-24 Thread Tore Bostrup
Assuming that you *don't* want ALL purchases made prior to the range, but only those of subjects not purchased recently, the following query appears to work: -- First gather info about recent purchases Create TEMPORARY Table recent SELECT B.id, B.date_purch, S.subj FROM subj as S INNER JOIN book

Re: Help with a putting a slash into a record in mysql...

2003-02-24 Thread Tore Bostrup
Try prefixing the \ (the ***x escape character) with a \, i.e.: update test set f2 = 'c:\\temp' where f1 = 'location' HTH, Tore. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 24, 2003 5:52 PM Subject: Help with a putting a slash into a reco

Re: Select from multiple tables

2003-02-24 Thread Tore Bostrup
First, you need to perform a JOIN on the two tables, otherwise you will get all combinations of rows from the two tables. But that is not what you are asking about. Using SELECT * is considered a bad programming practice. Always specify the select list (the columns you want to see/need to work o

Re: Unknown table in field list

2003-02-24 Thread Tore Bostrup
You are getting two rows not because there is one in parcels and one in building, but because one of the tables has two rows and the other has one that matches according to the WHERE clause and the join criteria. To see the "source data", do separate selects on the two tables: select * from parce

Re: # of Business Days?

2003-02-24 Thread Tore Bostrup
If you truly want only business days - i.e. you don't want to count Holidays - the only solution is to have a tables with all the business days. You'd populate this periodically with future dates as required, and a human may be required to mark off the holidays (unless you can create an algorithm t

Re: Directory structure

2003-02-24 Thread Tore Bostrup
Depending on how you plan to use the data, you may be interested in the "Nested Set Model". There are articles listed at searchdatabase.techtarget.com if you search for that string, but you may need to register there (can't supply links as they contain user ID...). Or if you have Joe Celko's SQL

Re: Unknown table in field list

2003-02-24 Thread Tore Bostrup
Just what it says. Your first query attempts to list a column from a table that is not selected from (building). Your second query attempts to assign the alias "building" to both the parcels table and the building table, and then subsequently does a join on the building table. Use the following

Re: Large table or several tables ?

2003-02-24 Thread Tore Bostrup
4 million rows is a large table, but not a huge table. 400 is a large number of tables. Does the data in the 400 arrays describe the same type of entity or do they provide *generic* attribute info for different types of entities? If so, they would logically belong in a single table, otherwise no

Re: Newbie - How To Link Two Databases

2003-02-22 Thread Tore Bostrup
First, it appears that you are confusing "database" with table. A Database is a collection of tables. Each table has rows of data which is organized in columns. >From what I understand, you have the following situation: Table: Parcels Columns: dxf (Primary Key, auto_number) [Descriptio

Re: big table, slow queries...???

2003-02-22 Thread Tore Bostrup
Use EXPLAIN to determine what indexes are chosen in the different cases. AFAIK, version 4 will allow you to specify HINTs in the query, so you may be able to force the query to use certain indexes. There are a lot of factors that affect the execution and speed of queries, including (but not limite

Re: big table, slow queries...???

2003-02-22 Thread Tore Bostrup
Unless your WHERE clause includes relationships for all the tables, you are dealing with a Cartesian product - that is always slow. And if you do have all the relationships included, this is still a monster query. Do you have the proper indexes defined? Do you really need to join these 5 tables

Re: Another Query Table Structure

2003-02-22 Thread Tore Bostrup
When designing a database, think of it this way: The "kinds of things" that you need to keep information about would map to the first cut of what tables you need. So if you keep information about Companies and Cities, you need (at least) the tables Companies and Cities. Keep information (attribut

Re: Query syntax help?

2003-02-22 Thread Tore Bostrup
Try: SELECT FF.name AS thename, MAX(FF.label) AS thelabel, F.name AS fieldsname FROM regformfields as FF INNER JOIN regfields as F ON (FF.name = F.Name) WHERE FF.label != '' GROUP BY FF.name, F.name I don't think you can include the ORDER BY F.saveorder (anot

Re: decimal type

2003-02-21 Thread Tore Bostrup
You are less likely to run into the issue when there are no calculations involved, but I wouldn't guarantee it. If you want to be on the safe side when using floating pont, do not check for EQUAL to, but within a range (+/- some small delta). As a rule of thumb, avoid floating point except for si

Re: decimal type

2003-02-21 Thread Tore Bostrup
When you don't specify the precision for a DECIMAL column, it is assumed to be 0. This is documented in the previously posted link. create table pricelist (product varchar(45), cost dec(18, 2)) HTH, Tore. - Original Message - From: "Bryan Koschmann - GKT" <[EMAIL PROTECTED]> To: "gerald

Re: From Win2000/IIS to Linux/Apache ?

2003-02-21 Thread Tore Bostrup
Moving the database is childs play. I'm sure other tools allow you to do this, but when I recently started working with MySQL, I found PremiumSoft MySQL Studio (30 day trial, $78 to purchase) from http://www.mysqlstudio.com It is a pretty decent tool, and among other things includes a Backup/data

Re: PHP / MYSQL Question

2003-02-21 Thread Tore Bostrup
This type of presentation must be produced by code - either your application (i.e. in your PHP code) or by a report generator. SQL statements always return data in a tabular format, i.e. (Topic, Question) 1,1 1,2 1,3 1,4 2,1 2,2 ...etc. In your presentation loop (PHP), remember the "previous" va

Re: Join or Group By?

2003-02-20 Thread Tore Bostrup
What you are looking for is a report generator. SQL queries will return result sets in a "table" layout (since the fonts etc. messes up attempt at tabulat layout, I'm presenting the data as comma separated): (SeriesTitle, LinkTitle) 1, 1 1, 2 1, 3 2, 1 2, 2 3, 3 If the Series column in the Links

Re: INSERT ... SELECT - A slightly different question

2003-02-20 Thread Tore Bostrup
The typical syntax for this would be: INSERT INTO phone (personID, phoneNr, email, type) SELECT personID, '1-xxx-xxx-', \N, 'OFF' FROM persons WHERE lastName='' HTH, Tore. - Original Message - From: "Kyle Lange" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, Febru