feha
|
| Posted: 03/22/2002, 8:41 AM |
|
MySQL Query is like:
$lookup_cat_name = db_fill_array ("select DISTINCT GroupNo,Name,cat_name
from categories, intermediategroup where GroupNo !=cat_name order by 2");
cat_name is column from table categories and GroupNo is column from table intermediategroup ....(they have same format example 104 )
I would like that after this query the GroupNo should caontain only values not found or not equal to cat_name...
(if 104 found in cat_name should not be cotained later in GroupNo)
Thank You in Advance...
|
|
|
 |
Nicole
|
| Posted: 03/23/2002, 1:36 AM |
|
Feha,
the problem isn't clear for me. If it is with sql query itself test it first against db, then paste to CC project.
|
|
|
 |
feha
|
| Posted: 03/23/2002, 2:18 AM |
|
Helo Nicole...
I would like to select from the table of intermediategroup and column GroupNo only values which aren't in another table of categories and in cat_name.
This would select automaticaly the values i added from the table of intermediategroup to the table of categories ("physically" they are still in GroupNo column...)
|
|
|
 |
Brent
|
| Posted: 03/24/2002, 3:11 PM |
|
Basically you want to use a subselect like:
select * from table1 where column1 not exists (select column2 from table2)
You need to do a left join as in:
select table1.* from table1 left join table2 on table1.col1 = table2.col2
where table2.col2 is null
|
|
|
 |
feha
|
| Posted: 03/24/2002, 10:30 PM |
|
Thank You Brent
What I need to do is:
That $lookup_cat_name should contain array of (not repeated) values from GroupNo which are new or not with in the cat_name...
Or how to select only the values from the tableA columnZZZ which doesn't exist on table B columnXXX...
Thank You
feha
|
|
|
 |
feha
|
| Posted: 03/25/2002, 12:56 AM |
|
here is the code...
-----
$lookup_cat_name = db_fill_array ("select DISTINCT RIGHT(IntermediateGroupNo,3),
SUBSTRING_INDEX(Name,' ',1),cat_name
from categories, intermediategroup where RIGHT(IntermediateGroupNo,3) NOT LIKE cat_name order by 2");
//If I set LIKE it works ok... but shows only values contained at cat_name,I want it oposite...
//-------------------------------
//Drop down select categories from main DB
//-------------------------------
if(is_array($lookup_cat_name))
{
reset($lookup_cat_name);
while(list($key, $value) = each($lookup_cat_name)){
if($key == $fldcat_name)
$option="<option SELECTED value=\"$key\"> $value [$key]";
else
if($key){
$option="<option value=\"$key\"> $value [$key]";
}
echo $option;
}
}
?></select></font>
....
Please Help Any Idea?
|
|
|
 |
|