Re: Problem with Oracle query
| From: | roy dot a dot jones at gsk dot com | Date: | Fri, 13 Oct 2006 14:59:20 +0000 |
| Subject: | Re: Problem with Oracle query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42540@lists.php.net to get a copy of this message | ||
Try this ...
SELECT m.id
,m.text
FROM main m
,recs r
WHERE m.id = r.id
AND r.log like '%sometext%'
ORDER BY m.id
/
Roy A. Jones
"Rick" <rosen@pernikinfo.com>
13-Oct-2006 10:53
To
php-db@lists.php.net
cc
Subject
Re: [PHP-DB] Problem with Oracle query
"Brad Bonkoski" <bbonkoski@mediaguide.com> wrote in message
news:452FA592.6020602@mediaguide.com...
> Rosen wrote:
>> Hi,
>> I have a problem with PHP and Oracle SQL query.
>> I have 2 tables :
>>
>> Table Main:
>> -----------
>> id number
>> text varchar2(100)
>>
>>
>> Table Recs
>> -----------
>> id number
>> pos number
>> log varchar2(200)
>>
>> I need to make query to select a list from first table(Main), where
>> somewhere in the second table (Recs), the log field contains some
string.
>> The records for one ID from Main table can be many in table Recs. (
Table
>> Recs acts as log for every row from table Main).
>>
>> Can someone help me with this query?
>>
>> Thanks in advance,
>> Rosen
>>
> select m.id, r.log from main m left outer join recs r on r.id = m.id
>
> This will output something like:
> Id log
> 1 log item 1
> 1 log item 2
> 1 log item 3
> 2 another log
> etc...
Thanks, but I want to retrieve only one row for ID field (row from Main
table) where the string contains in second table.
Something like this:
ID Text
1 Sometext 1
2 Sometext 2
6 Sometext 3
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php