SQL 2 Table Question

SQL 2 Table Question

Postby Jimmy » Sat Jan 22, 2022 4:24 pm

hi,

it is not a special FiveWin Question

as i know i can use 2 Table in SQL-Statement when using "A(lia)S"
Code: Select all  Expand view
"SELECT a.text1, b.__text1 FROM sqldata AS a, sqlindex AS b"

when both have Table "same length", will it be "sync" when "navigate" in Table :?:

---

when using ADO i get a Record-Set from Table sqldata
but how "sync" Table sqlindex when have cFor, cWhile and nOffset ... or will it be "in Sync" :?:

or do i need a (internal) FIELD __Record in both Table to "sync" :idea:

---

as i know "older" SQL Version can create a "real" SLQ Index only from 1 x FIELD
so FIELD1 + FIELD2 will not work like in xBase as IndexKey

the Idea is to create a second Table sqlindex
when create a Table sqlindex i can create a FIELD which can hold Value of FIELD1 + FIELD2 as IndexKey
when change ORDER all Information are in same ROW and i can use Table sqlindex "internal" as ORDER

can this Concept work :?:
Comment welcome
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: SQL 2 Table Question

Postby Enrico Maria Giordano » Sat Jan 22, 2022 8:28 pm

Jimmy wrote:
Code: Select all  Expand view
"SELECT a.text1, b.__text1 FROM sqldata AS a, sqlindex AS b"


This join is incomplete as it lacks of the WHERE clause. Without it you would get a recordset of n1 * n2 records. You have to use something like

Code: Select all  Expand view
WHERE id1 = id2


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SQL 2 Table Question

Postby Jimmy » Sat Jan 22, 2022 11:07 pm

hi Enrico,

This join is incomplete as it lacks of the WHERE clause.

yes you are right

i need a "Relation"
so i add "internal" FIELD __Record and use
Code: Select all  Expand view
   cQuery := "CREATE TABLE " + xtab + " ( "
   ...
   cQuery += " __record     serial  NOT NULL, "
   cQuery += " CONSTRAINT " + xtab + "_pkey PRIMARY KEY (__record)"
   cQuery += " )"                                
 

and change to

Code: Select all  Expand view
"SELECT a.text1,a__Record,b.__text1,b.__Record FROM sqldata AS a, sqlindex AS b where a.__Record = b.__Record"

Ok now i can begin to add "more" where, ORDER, OFFSET and LIMIT for "navigation"
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests