Re: Search?

2003-08-23 Thread Andy Jackman
Pieter, If you use LIKE '%abc%' then this will match 'abc' 'abcs' 'ABC' 'DABCE' 'DABC' and 'ABCD'. It will not match 'AB'. In your case it may work better if you validate the words before you run your SELECT statement or make your fields more specific. For example, instead of a field called descr

Re: Oracle DBA here looking for advice on MySQL ....

2003-08-19 Thread Andy Jackman
I've used a lot of Oracle, some MS Access and I'm newish to MySQL. I found it easy to write an abstraction layer for Ms Access and Oracle despite their different approaches to some important things. I find MySQL very sparse by comparison and I spend more time working round the db than working with

Re: Better query method?

2003-08-16 Thread Andy Jackman
John, I was intrigued with the given solution so I tried this and here's a version I found to work: Table x1 has fields uid, uname, pid (parent's id) select parent.uname, count( child.uname) as ChildCount from x1 as parent left join x1 as child on ( parent.uID=child.pid) group by parent.uName

Re: Double entries

2003-08-16 Thread Andy Jackman
Trevor, Why not try simplify it to 2 fields and remove most of the validation code? If that works, then you can binary add/delete code until it fails. BTW 'Red' I guess only works on certain mail clients, but not mine, so sorry if I missed something obvious. Regards, Andy. Trevor Morrison wrote:

Re: how to 'tell' the select what to omit

2003-08-14 Thread Andy Jackman
As Victoria says, you can't. However I agree that this syntax is useless in many real-world situations. You are not the only one who finds this behaviour annoying. It's about time someone made SQL a 21st century language... Miroslav I. wrote: Hallo suppose you have a table with great

Unix date problems

2003-08-14 Thread Andy Jackman
Hi, 1) I was investigating the unix_timestamp routine in mysql (version 3.23.46-nt) and for some reason the unix epoch (1-1-1970) was returned with a value of -3600. Then, as you can see, it suddenly corrected itself. I can't replicate this error, but it caused me to shudder. Attached is the

Re: Newbie SQL question

2003-08-14 Thread Andy Jackman
Keith, You're on the right track. But instead of 2 tables, pretend you have three. 1) Home Teams, 2) Schedule 3) Opponent Teams. In reality tables 1 and 3 are the same table, but you mus't get confused between using 'Teams' as Home Teams and Teams as Opponents. In the same way as you named columns

Re: Use Like or =

2003-08-14 Thread Andy Jackman
Eli, Use = for exact matches and LIKE for partial matches using a wild card e.g. WHERE column_name LIKE ab% will match 'ab', 'abc' and 'ABC' but not 'acb'. Regards, Andy eli wrote: Hi, I have a question about using LIKE or equal. I mean, comparing two strings with exact coincidence,

Re: Unix date problems

2003-08-14 Thread Andy Jackman
- that's the scary bit. - Andy Keith C. Ivey wrote: On 7 Aug 2003 at 15:27, Andy Jackman wrote: 1) I was investigating the unix_timestamp routine in mysql (version 3.23.46-nt) and for some reason the unix epoch (1-1-1970) was returned with a value of -3600. That's what I'd expect

Re: arbitrary ordering

2003-08-12 Thread Andy Jackman
David, Gah. That's what I was hoping to avoid. It's like writing BASIC and having to leave yourself room... Yes, but unlike a basic program of 1 lines (heh, remember that!) you only need to leave room for n questions. If n is small - no problem, even if you have to 'renumber'. If n is

Re: Help debugging this Query?

2003-08-12 Thread Andy Jackman
Aaron, It sounds like the join has duplicates on both sides. If you join a-b where a is unique (like a primary key) then you will get count(b) records (where b is the rows that match a). Or if b is unique then you will get count(a) records. However if neither a or b is unique you get count(a) *

Re: arbitrary ordering

2003-08-10 Thread Andy Jackman
David, Firstly, to answer your question I don't know of a MySQL function that may allow you to sort indirectly by the contents of a field - there are many many functions and some of them are very specialised, and if you ever move to another db all those great little functions may not be there.

FROM_DAYS doesn't take timestamp?

2003-08-09 Thread Andy Jackman
Hi, I'm using v 3.23.46-nt and the C API. The manual says under 'Changes in release 3.20.17' that: Change FROM_DAYS() and WEEKDAY() to also take a full TIMESTAMP or DATETIME as argument. Before they only took a number of type MMDD or YYMMDD. I'm confused since this doesn't seem to be the

Re: Adv. Mysql query

2003-08-03 Thread Andy Jackman
Mattias, Your 'blueprint' table looks good. This where itemID corresponds to a item in the master table and the componentID ALSO referes to items in the Master table??? Correct. This allows 'recursive' components. For example, Item 3 contains components 1,3,4 and component 4 is actually made

Re: Slowing brute force attack

2003-08-03 Thread Andy Jackman
David, Is it possible to cause the client to wait by the server issuing a SLEEP? What if the client just disconnectes and immeadiately reconnects? Say you use a sleep of 2 seconds. If your server can accept 100 connections at once then 1 client can issue 100 login attempts and wait 2 seconds for

Re: C API AND MYSQL

2003-08-02 Thread Andy Jackman
Dave, The documentation has several examples. Here's a function we use. Are you having a particular difficulty? Regards, Andy. snip MYSQL *aDb = NULL; int xConnect() { #define MYSQL_HOST 192.168.103.112 // or host name #define MYSQL_DBfoodb // database

Re: ERROR while compiling:

2003-08-02 Thread Andy Jackman
Prem, I had this problem and adding the library 'z' (whatever that is) helped. Try putting -lz at the end of your compile line. Regards, Andy. Prem Soman wrote: i am using Linux 6.2(Zoot) and MySql 2.23.36and found the following error while compiling the C program using mysql APIcc -o test

Re: Date to Days Query

2003-08-02 Thread Andy Jackman
Mike, Is the field days meant to be the number of days until expdate? (This is implied by the number 14 you gave). If so, you shouldn't be storing the days value in the database at all (the reason being it causes exactly the problem you seem to have). Instead you should store only expdate and

Re: Adv. Mysql query

2003-08-02 Thread Andy Jackman
Mattias, It may not be such a good idea to store the 6 items in 1 record. An alternative structure is one table with Item ID and Name and another with Item Id and Component Id, both of which point back to item id in the first table. This avoids having to know how many components there are and

Re: NON web based client server applications

2003-08-02 Thread Andy Jackman
KB, 1) There's an interesting virus alert attached to your message. 2) what front end tools should i think of using for dataentry clients IMHO, the answer is 'the web'. Is there a good reason why you don't want to do that? I realise that JSP is an obvious choice and perhaps like me you think it

Re: UNION or not?

2003-08-01 Thread Andy Jackman
Gary, The if() function often allows you to replace a union query. For example this may work for you - watch the LIMIT it operates AFTER the sort so your sort needs to put the records which you want at the front: SELECT user_id, username, last_login, if(last_team = 380, 1, 2) as SortOrder FROM

Re: Advice wanted on Data Structure

2003-07-30 Thread Andy Jackman
Donald, I've done this before - it wasn't nice. The best solution I came up with was to store the kits in the item table as though they were items. So the structure is: (Lets call a 'Product' an Item or a Kit depending on the 'prod_type') PRODUCT KIT CONTENTSPRODUCT

Re: When mysql ruinned by Disaster

2003-07-29 Thread Andy Jackman
MaFai, But the ip address would change too If this system is running on a LAN why would it be a problem to change the DNS or are you trying to connect other clients (e.g. from the web?) - Andy MaFai wrote: Hello, mysql, We have 1 master and salve in my lan. If the master failed,coze the

Re: dbase calculations

2003-07-28 Thread Andy Jackman
Kalle, The usual way to do this is to create the table with the 2 real fields and then use a query to 'create' the sum field at run time. For example assume you have this table: create table my_table ( field_1 int(9), field_2 int(9) ); then you can write this query: SELECT

Atomicity of a SELECT/UPDATE

2003-07-28 Thread Andy Jackman
Hi, I want to get any one of a number of rows that matches some criteria and update it so that it is marked as 'mine'. How can I do this safely? Given something like this table: create table tbl_new ( t_value varchar(16) primary key not null, dt_used datetime, l_pid

Re: Deleting duplicating records

2003-07-28 Thread Andy Jackman
There a bit of discussion like this in the user comments of the manual: http://www.mysql.com/doc/en/example-Maximum-row.html - Andy Venelin Arnaoudov wrote: I would copy all the records (_email_, max(version)) to a new table, drop the old one and then rename the new one Regards, Venelin

How to retrieve integer in C prog?

2003-07-26 Thread Andy Jackman
Hi, I'm new to mySql. I've got a table with an integer field defined like this: l_start_wait int(9) not null I inserted a value into the table using mysql command line client with: Insert into tbl_wait_list values(12345678); When I use mysql_fetch_row() to retrieve the column values I am