Since the days in a week are not likely to change, why not have an indexed
column for each day? For example,

select id from courses where day_m = 1 and day_t = 0 and day_w = 1 and day_h
= 0 and day_f = 1;

Wouldn't this approach be more efficient than a full table scan with regular
expression matching on each row? You could add two more columns, days_mwf
and days_th, to speed up the common queries.

Bret

-----Original Message-----
From: Matthew Walker [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 3:46 PM
To: Douglas Brantz; [EMAIL PROTECTED]
Subject: RE: Pattern Matching Problem


SELECT schdays FROM courses WHERE (schdays LIKE "M") OR (schdays LIKE
"W") OR (schdays LIKE "F")

Matthew Walker
Ecommerce Project Manager
Mountain Top Herbs


-----Original Message-----
From: Douglas Brantz [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 29, 2002 1:15 PM
To: [EMAIL PROTECTED]
Subject: Pattern Matching Problem

Hello,

I have a big problem! I need to match all patterns in schdays from a
variable schdays and if schdays = mwf it only turns up mwf and not all
entries containing M, W or F.  Is there a way to do this?  

mysql> select schdays from courses where schdays LIKE "%MWF%";
+---------+
| schdays |
+---------+
| MWF     |
+---------+
1 row in set (0.00 sec)

mysql> select schdays from courses where schdays LIKE "%M%";
+---------+
| schdays |
+---------+
| MWF     |
| MW      |
| MW      |
| M       |
| M       |
+---------+
5 rows in set (0.00 sec)

I need to be able to say select schdays from courses where schdays LIKE
"%schdays%"


Here is my code from the program:
my $sth2 = $dbh->prepare("select
id,schdays,time_to_sec(timein),time_to_sec(time
out) from courses where schdays LIKE \"\%$cschdays\%\" AND
done=\"Yes\"....etc..


So I need to be able to match any pattern with $cschdays.
Do I need to parse out the letters and pattern match each one??  It
should be easier.

Thanks,
Douglas
[EMAIL PROTECTED]

--
Douglas R. Brantz
Computer Consultant
Fine & Applied Arts
Appalachian State University
Boone, NC 28608

828-262-6549 (office)
828-262-6312 (fax)




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 1/21/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 1/21/2002
 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to