FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SQL 2 Table Question
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
SQL 2 Table Question
Posted: Sat Jan 22, 2022 04: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 (fw): Select all Collapse
"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" :-)

---

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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: SQL 2 Table Question
Posted: Sat Jan 22, 2022 08:28 PM
Jimmy wrote:
Code (fw): Select all Collapse
"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 (fw): Select all Collapse
WHERE id1 = id2


EMG
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: SQL 2 Table Question
Posted: 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 (fw): Select all Collapse
    cQuery := "CREATE TABLE " + xtab + " ( "
   ...
   cQuery += " __record     serial  NOT NULL, "
   cQuery += " CONSTRAINT " + xtab + "_pkey PRIMARY KEY (__record)"
   cQuery += " )"

and change to

Code (fw): Select all Collapse
"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

Continue the discussion