Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with SPT code
Message
De
09/08/2002 11:23:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/08/2002 11:05:08
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00686974
Message ID:
00688013
Vues:
35
>Cetin,
>
>I am still having trouble with this and those I support are breathing hot and heavy for my soultion. My solution lies in your expertise with SQL statements. I will try to explain my situation again because in the message you sent me before there might have been some question as to what I need.
>
>I have one table in AS400. It has a field of document numbers and a field of descriptions. In the table for what ever reason the same document number can be listed many times each with a different portion of the description. So to get a complete picture of the document all the records of that number have to be brought together.
>
>Now my sistuation. I want to query the AS400 table by a word that is in the description. Say the word 'CLOTH'. I will get every record that the word 'CLOTH' is in. But I will not necessarly get all the records of each document since the word 'CLOTH' is not in every line of the description.
>
>So I need some way to pull up all the document records that have the word 'CLOTH' in any part of the description.

Let me see if I understood it right :
DocNum Description
------ -------------
1      Some description
2      In our excellent washers 
1      Some more description
2      you can safely
3      Wear heavy clothing when
2      wash any type of clothes
3      leaving for arctics
If you put poor English a part your query should return ? :
DocNum Description
------ -------------
2      In our excellent washers 
2      you can safely
2      wash any type of clothes
3      Wear heavy clothing when
3      leaving for arctics
SQL1 (Get DocNums) - don't know AS400 function support, guess supports upper() and maybe even some more easier ones :

select distinct DocNum from myTable where upper(Description) like '%CLOTH%'

SQL2 (Get a series of records) :
select * from myTable

Combine with a where :
select * from myTable ;
  where DocNum in ;
 ( select distinct DocNum from myTable ;
   where upper(Description) like '%CLOTH%' ) ;
  order by DocNum
or
select * from myTable t1 ;
  where exists ;
 ( select * from myTable t2 ;
   where t1.DocNum = t2.DocNum and ;
      upper(Description) like '%CLOTH%' ) ;
  order by DocNum
lnResult = SQLExec(gnHandle, 
  "select * from myTable"+ ;
  "  where DocNum in "+;
  " ( select distinct DocNum from myTable "+;
  "   where upper(Description) like '%CLOTH%' ) "+;
  "  order by DocNum", 'myCursor')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform