Getting count() to include 0 counts in select - slow

2004-11-11 Thread Mark Worsdall
SELECT _objectives.id, _objectives.name, COUNT(go._iso._objective_id) FROM go._objectives INNER JOIN go._subjectHeadings         ON go._subjectHeadings.id = go._objectives.subjectHeadings_id INNER JOIN go._subjects         ON go._subjects.id = go._objectives.subjects_id LEFT JOIN go._iso        

Re: Getting count() to include 0 counts in select

2004-11-10 Thread Mark Worsdall
uld fit:-) But I get it. I just love mySQL, it has removed so many layers of complication from my coding life and left only 1 layer of not too much complicatedness:-) Site below is powered by mySQL. M. -- Mark Worsdall http://www.vote4president.net -- MySQL General Mailing List For list

Re: Getting count() to include 0 counts in select

2004-11-10 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes Change one of your INNER JOINS to a LEFT JOIN. (The comma separated list of table names is actually a sneaky way to declare INNER JOINS). That way you will see all of the _objectives records whether or not they appear in _iso or any of the

Getting count() to include 0 counts in select

2004-11-10 Thread Mark Worsdall
each record do the following to determine if this id is in use. SELECT COUNT(*) FROM go._iso, go._ltaForm WHERE _objective_id = $objectiveID AND _ltaForm.id = _iso.ltaForm_id ($objectiveID = $row[0] from 1st query) -- Mark Worsdall https://www.paypal.com/refer/pal=LS79YHQ9VUGLJ -- MySQL General

Can't get count(go._iso._objective_id) to return 0 values

2004-11-08 Thread Mark Worsdall
I am trying to merge the following 2 selects into one select. !!! Returns all custom objectives. Another check is needed to see if in use. !!! SELECT _objectives.id, _objectives.subjects_id, _objectives.subjectHeadings_id, _objectives.name, _objectives.active, _objectives.displayOrder FROM go._obj

How to read table names within database?

2002-09-05 Thread Mark Worsdall
Hi, I notice that lots of mysql gui's all can find out the contents (tables) of any given database, how do they do this? Is it an sql command? I hope so, I need to know what the SQL command is so I can pass it to perl DBI. M. -- Mark Worsdall https://www.paypal.com/refer/pal=LS79YHQ9

Re: BLOB insert problem used ' '

2002-07-09 Thread Mark Worsdall
Hi all, Sorry should have got my mind around the LOAD_FILE('./image.tiff') method. M. In message <[EMAIL PROTECTED]>, Mark Worsdall <[EMAIL PROTECTED]> writes >Hi, > >After a good old slurp of an image< I am trying to stick it into my >table. > > &

BLOB insert problem used ' '

2002-07-06 Thread Mark Worsdall
Hi, After a good old slurp of an image< I am trying to stick it into my table. # Slurp file foreach (@image_list) { my $image = "/usr/home/shadow/Vision/$_"; # Load image into memory my $imagePIC = do { local ($/, *PIC); # slurp mode, local file handle open PIC, $image or d

Re: Can this can be done in a single SQL statement?

2002-01-27 Thread Mark Worsdall
Hi DN, Boy SQL is damn powerful!!! I see what you mean by having my head switch the way it is thinking and a lot of penny's dropped this afternoon, Thankyou. In the end I did this: SELECT studentname_27.objectives_id, studentname_27.data, staff.name, studentname_27.date,

Can this can be done in a single SQL statement?

2002-01-26 Thread Mark Worsdall
Hi All, Can anyone tell me if this can be done in a single SQL statement? Well I have this data stored in a table called _worsdallm which looks like this:- id int(10) NOT NULL auto_increment objectives_id int(10) data varchar(254) staff_id int(10) date timestamp NOT NULL PRIMARY KEY (id))

Re: is there a timestamp function for a table

2001-12-01 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, Mark Worsdall <[EMAIL PROTECTED]> writes >Hi, > >Want I need is to find out when a table was last updated, not a records >timestamp. > >Is there a way? > >or for SW people: > >way is there a? > > Obviously

is there a timestamp function for a table

2001-11-30 Thread Mark Worsdall
Hi, Want I need is to find out when a table was last updated, not a records timestamp. Is there a way? or for SW people: way is there a? -- Work:- postmasterAThinwick.demon.co.uk - Before posting, please check: http://

Re: Suggestion: Formatting TimeStamp columns

2001-11-29 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, Thomas Spahni <[EMAIL PROTECTED]> writes >On Mon, 26 Nov 2001, Brent wrote: > >> A Select statement will display the TmeStamp as 2005095105. Now I ask >> you, how many users will understand this format? >> Why not display TimeStamp in the same format as DateTim

Re: Having trouble using LIMIT

2001-10-31 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, Steve Meyers <[EMAIL PROTECTED]> writes >> But when I add in the LIMIT statement it returns no records >> >> $prep = "SELECT id,name FROM go.objectives WHERE subjects_id='1' AND >> subjectHeadings_id='2' LIMIT 1,5 ORDER BY displayOrder"; >> >> $sth = $dbh->prepare(

Re: HOW do I return the results of a count to a variable

2001-10-31 Thread Mark Worsdall
In message <p0510031bb805065122c6@[192.168.1.31]>, Paul DuBois <[EMAIL PROTECTED]> writes >At 12:43 AM + 10/31/01, Mark Worsdall wrote: >>Hi, >> >>I want to alter this statement so it returns the number of records. >> >>$prep = "SELECT COU

Having trouble using LIMIT

2001-10-30 Thread Mark Worsdall
Hi, When I do the following in a perl script I get back all the records I want: $prep = "SELECT id,name FROM go.objectives WHERE subjects_id='1' AND subjectHeadings_id='2' ORDER BY displayOrder"; $sth = $dbh->prepare($prep); $sth->execute; But when I add in the LIMIT statement it returns

HOW do I return the results of a count to a variable

2001-10-30 Thread Mark Worsdall
Hi, I want to alter this statement so it returns the number of records. $prep = "SELECT COUNT(*) FROM go.objectives WHERE subjects_id='1' AND subjectHeadings_id='2' ORDER BY displayOrder"; $sth = $dbh->prepare($prep); $sth->execute; So what I need to do is add the COUNT statement into the ab

I need help constructing a regexp

2001-07-27 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, Mark Worsdall <[EMAIL PROTECTED]> writes >Hi all, > >I have a problem, I have some VARCHAR data in a column called Sequence >looking like this:- > >5;6 >12;6 >120;6 >5;6;1 >12;6;12 >120;6;105 > >So there could b

REGEXP syntax

2001-07-27 Thread Mark Worsdall
Hi, Trying to get to grips with regexp but really want to 1st get a simple expression working with mysql. SELECT Sequence, Message, id FROM $sqlTable WHERE Sequence REGEXP(\"^$filterValue;\") The above works for finding matched values, where the number = to $filterValue is in in the 1st part

Re: I need help constructing a search thingy using % & _ in LIKE

2001-07-26 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, tj marlin <[EMAIL PROTECTED]> writes >I think it is time for you to learn about regular expressions; page 520 >ff of Dubois. >(sql, mysql, database - to get past the filter) > any chance of an example or full syntax? M. -- Work:- postmasterAThinwick.demon.co

I need help constructing a search thingy using % & _ in LIKE

2001-07-25 Thread Mark Worsdall
Hi all, I have a problem, I have some VARCHAR data in a column called Sequence looking like this:- 5;6 12;6 120;6 5;6;1 12;6;12 120;6;105 So there could be anything from 2 to n numbers seperated by ; Each number could be 1 to 3 digits long (eg 5 12 or 121). I have tried various searches like

Re: how to

2001-05-29 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, Tonu Samuel <[EMAIL PROTECTED]> writes >On 29 May 2001 09:28:04 +0200, Signe Hasseriis wrote: >> Please tell me how to select the 10 (or 5) newest records or posts >>from a MySql table. >> > > >SELECT * FROM table ORDER BY posttime DESC LIMIT 5 is the column/fiel

upgrading mySQL, definitive procedure wanted

2001-05-29 Thread Mark Worsdall
Hi, If one installs a newer version of mysql over the top of a current version (in my case this will be done from the FreeBSD ports collection), will the current tables and data remain intact? If not OR if a worry, is there a single command using mysqldump to dump everything in one go, knowin

Re: mysql uses 99% cpu under freebsd 4.3

2001-04-12 Thread Mark Worsdall
Hi, I have had some various similar things happen with other apps since upgrading to Fbsd4.2stable What I have learnt to do first before anything else is, reboot and load a SINGLE CPU compiled kernel to determine at what/where the bug may be. I had a/still occasionally get a constant waiting

How do I get tableName.Colname after doing a select, I can only get col name

2001-04-09 Thread Mark Worsdall
Hi, I am doing a select from to tables which are join'ed, I cannot determine automatically which table a column belongs to:- I have tried both these selects:- SELECT * FROM staff, staffsubjectTitles WHERE staff.id = 11 AND staffsubjectTitles.staff_id = 11 SELECT staff.*, staffsubjectTitles.*

INSERT of not exists

2001-03-27 Thread Mark Worsdall
Hi, I am trying to write a query that will INSERT into a table a set of values if they do not already exist. It is a join table. $colOneName = 'staff_id'; $colTwoName = 'subject_id'; $colOneValue = 2; $colTwoValue = 3; $sth = $dbh->prepare ("REPLACE into $sqlTable ($colOneName, $colTwoNam

ADVICE: Best way to store multi values

2001-03-21 Thread Mark Worsdall
Hi, I have a table called staff which currently has a column called subjectTitles_id which is the type INTEGER. I have another table called subjectTitles which contains 12 subject titles. So that is how a member of staff is assigned a subject. Trouble is I need to be able to assign a multipl

Re: ADVICE: Best way to store multi values

2001-03-20 Thread Mark Worsdall
lt;[EMAIL PROTECTED]> writes >Assuming you have table staff with an id and name, >and title with id and title, >You create a join table. >Staff_id Title_id >1 1 >1 2 >2 1 >2 3 > >Then: >Select name,title >FROM staff s , title t, jointable j >WHE

Still cannot extract enum values from column

2001-03-15 Thread Mark Worsdall
Hi, While searching the net I came across some perl to get enum values from a table column, but I can't get it to work due to my lack of understanding of what is going on, I am not even sure I have read the data correctly. my $sth = $dbh->prepare("SELECT $column FROM $sqlTable"); $sth

Re: HOWTO: Get column types & enum values using perl

2001-03-14 Thread Mark Worsdall
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes >$sth->{TYPE} returns a reference to an array of types. > >$types = $sth->{TYPE} > >if ($$type[0] = &Mysql::FIELD_TYPE_STRING) > >(I don't know about the Mysql::FIELD_TYPE_STRING, but $$type[0] is the >type of the first field.) > When I do

HOWTO: Get column types & enum values using perl

2001-03-14 Thread Mark Worsdall
Hi, I posted before but the help did not yield any success, sorry but thanks. Any one else help? In message <[EMAIL PROTECTED]>, Mark Worsdall <[EMAIL PROTECTED]> writes >Hi, > >I am trying to read the field types (as well as 1 row of data and the >field names), but I

HOWTO: Read enum values from a field?

2001-03-13 Thread Mark Worsdall
Hi, When reading field names (or a row of data) how does one read the possible enum values, so I can put them in a drop down menu? M. -- He came from Econet - Oh no, I've run out of underpants :( Home:- [EMAIL PROTECTED] http://www.wizdom.org.uk Shadow:- [EMAIL PROTECTED] http://www

HOWTO: Get field types?

2001-03-13 Thread Mark Worsdall
Hi, I am trying to read the field types (as well as 1 row of data and the field names), but I cannot seem to manage it. Any ideas on how? M. $sth = $dbh->prepare("SELECT * FROM $sqlTable WHERE id = $id"); $sth->execute; my $hash_ref= $sth->fetchrow_hashref; my @staffFields = keys(%{$hash_