| From: | Hunter Hillegas <lists(at)lastonepicked(dot)com> | 
|---|---|
| To: | PostgreSQL <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Query Help | 
| Date: | 2002-07-23 23:39:04 | 
| Message-ID: | B9633728.5B8D3%lists@lastonepicked.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
I'm looking for a little query help, if anyone has a free moment...
I have two tables:
CREATE TABLE message_board_topics (
    rec_num integer NOT NULL PRIMARY KEY,
    topic_name varchar(255),
    topic_body text,
    topic_author varchar(20),
    topic_author_email varchar(50),
    topic_date date,
    topic_updated datetime,
    number_of_comments integer
);
CREATE TABLE message_board_comments (
    rec_num integer NOT NULL PRIMARY KEY,
    topic_id integer REFERENCES message_board_topics,
    comment_parent integer,
    comment_name varchar(255),
    comment_body text,
    comment_author varchar(20),
    comment_author_email varchar(50),
    comment_date date
);
Anyway, I want to do a quick and dirty search against them... Basically I
want to find any message_board_topic where the submitted text matches either
the topic_name, topic_body, topic_author, or the comment_author of any
related comment...
I tried this:
SELECT * FROM message_board_topics, message_board_comments WHERE
upper(topic_name) LIKE upper('%test%') OR upper(topic_body) LIKE
upper('%test%') OR upper(topic_author) LIKE upper('%test%') OR
(upper(message_board_comments.comment_author) LIKE upper('%test%') AND
message_board_comments.topic_id = message_board_topics.rec_num) ORDER BY
message_board_topics.rec_num DESC;
Now, this returns no rows but this query that doesn't search the comments
table returns a row:
SELECT * FROM message_board_topics WHERE upper(topic_name) LIKE
upper('%test%') OR upper(topic_body) LIKE upper('%test%') OR
upper(topic_author) LIKE upper('%test%') ORDER BY
message_board_topics.rec_num DESC;
Any ideas what I am doing wrong? It would be a big help.
Thanks,
Hunter
| From | Date | Subject | |
|---|---|---|---|
| Next Message | miguel angel rojas aquino | 2002-07-24 00:00:03 | error modifying max_connections (maybe a little o.t.) | 
| Previous Message | Joe Conway | 2002-07-23 23:28:45 | Re: Access Two Databases |