* BUNTER MATTHEW
> I'm putting together a table that has dates of reign for a monarch.
> 
> What I eventually want to do is to be able to ask the question :
> 
> Who reigned during 1585? And get an answer of : King Joe
> 
> This info will be outputted in a php form on a web page.
> 
> So if the data I have is King Joe reigned from 1583 to 1587, how can I u=
> se
> this to be able to solve my question? What I'm after is format of this
> value, in one column or two, any extra things I should do etc.

Try something like this:

CREATE TABLE kings (
  id int not null primary key, 
  name varchar(50),
  reign_from smallint,
  reign_to smallint);

INSERT INTO kings VALUES (1,'King Joe',1583,1587);

SELECT * FROM kings 
  WHERE 
    1585 BETWEEN reign_from AND reign_to;

-- 
Roger
sql

---------------------------------------------------------------------
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