0

Guess there are similar questions and the answere might is easy but I cant help my self and thats why I ask you guys.

I have some Data in a DB (Centura/Gupta SQLBase 7) no Left/Right Join possible - obviously not implemented in sqlbase sql

Here is my select

SELECT 
    I.IARTNR, 
    L.ARTNAME 
FROM 
    INVENTUR I,
    LAGER L 
WHERE 
    L.ARTSTR = I.IARTNR 
AND
    I.AB = '2015-81';

returns 20 rows, not 18 as expacted.

INVENTUR rows with AB set to 2015-81 are 18 and in LAGER there are <3000 rows. What I'm trying to do is select all articles von INVENTUR and add the article name thats written in LAGER.

Whats wrong with my select ? Running this "mysterious" since 3 days.

Dwza
  • 6,494
  • 6
  • 41
  • 73
  • 2
    Have you tried using DISTINCT in SELECT statement? – Madhivanan Jan 19 '16 at 10:38
  • using distinct will propably cause problems when there are duplicated entrys. of course its and and should be possible to add duplicates like artnr 1234 amount 1 artnr 1234 amount 1 (what should return artnr 1234 total amount is 2) btw with distinct it returns only 14 rows because some artcle have the same name but different artno. – Dwza Jan 19 '16 at 10:45
  • Must you use that weird DB that does not have joins? – Gergely Bacso Jan 19 '16 at 10:56
  • sadly yes :( there are some customers (about 200) of my company and they use sell software based on this DB.... – Dwza Jan 19 '16 at 10:58
  • Have you tried using sub queries instead – Bayeni Jan 19 '16 at 12:05
  • after almost 3 days I found out that lager has 3 articles that 100% duplicate. duplicates in iventur is no problem but in lager it is. so cleaned up the 3 articles and that solved the result. thx for alle hints and helps! – Dwza Jan 19 '16 at 14:16
  • Thanks for the update Mr Dwza. Mr Basco FYI: SQLBase supports the following types of joins: • Equijoins • Outer joins • Self joins • Non-equijoins Heres a link to SQLBase online Help - support.guptatechnologies.com/supportwiki/index.php/ … – Steve Leighton Oct 03 '17 at 01:06

3 Answers3

1

ANSI join syntax for Outer / Inner joins was added in v8.5 onwards ( now upto v12.1 ). Before v8.5 , you can use the native Gupta Outer / Inner join syntax e.g.

SELECT t1.col1,t2.col1,t1.col2,t2.col2
FROM t1,t2
WHERE t1.col1 = t2.col1(+)
AND   t1.col2 = t2.col2(+)

The next example lists customer names and their order numbers,including customers who have made no orders:

SELECT CUSTOMER.CUSTNO,NAME
FROM CUSTOMER,ORDERS
WHERE CUSTOMER.CUSTNO = ORDERS.CUSTNO(*)

The same query using ANSI syntax in SQLBase v8.5 onmwards is:

SELECT CUSTOMER.CUSTNO,NAME 
FROM CUSTOMER LEFT OUTER JOIN ORDERS ON CUSTOMER.CUSTNO = ORDERS.CUSTNO
Steve Leighton
  • 790
  • 5
  • 15
  • As you can See in my sample, I use this way of select allready. The db is a 7.0.5 when I remember right. But thx for these informations. – Dwza Oct 03 '17 at 01:11
  • But why did you answered my question 2 times? :) – Dwza Oct 03 '17 at 01:12
0

Use explicit joins.

SELECT I.IARTNR, L.ARTNAME 
FROM INVENTUR I
INNER JOIN LAGER L ON I.IARTNR = L.ARTSTR
WHERE I.AB = '2015-81';

And if needs be DISTINCT.

SELECT DISTINCT I.IARTNR, L.ARTNAME 
FROM INVENTUR I
INNER JOIN LAGER L ON I.IARTNR = L.ARTSTR
WHERE I.AB = '2015-81';
Matt
  • 14,906
  • 27
  • 99
  • 149
  • as i sayed... i cant use join..obviously this command isnt implemented in that sql. – Dwza Jan 19 '16 at 10:45
  • 1
    For the record, SQLBase DOES fully support explicit ANSI joins as stated by Matt and earlier. Just include ANSIJoinSyntax=1 in the [dbntsrv] of sql.ini – Steve Leighton Mar 21 '18 at 02:27
0

Of course SQLBase has inner / outer joins ! Either Native syntax ( using (+) ) or ANSI .
Here's the syntax:

NATIVE: SELECT t1.col1, t2.col1, t1.col2, t2.col2 FROM t1, t2 WHERE t1.col1 = t2.col1 (+) AND t1.col2 = t2.col2 (+);

ANSI: SELECT t1.col1, t2.col1, t1.col2, t2.col2 FROM t2 RIGHT OUTER JOIN t1 ON t1.col1 = t2.col1 AND t1.col2 = t2.col2 ;

p.s. SQLBase is no 'weird' database . v12 recently released will outstrip SQLServer every time in terms of performance , footprint and overall cost of ownership. Please be more aware of your facts before broadcasting nonsense.

Steve Leighton
  • 790
  • 5
  • 15
  • Mr Dwza : If you cant use inner/outer joins in SQLBase - your doing it wrong . SQLBase supports all the following in either Native or ANSI formats : SQLBase supports the following types of joins: • Equijoins • Outer joins • Self joins • Non-equijoins Heres a link to SQLBase online Help - which you obviously could make use of . http://support.guptatechnologies.com/supportwiki/index.php/SQLBase_12_Documentation – Steve Leighton Jan 20 '16 at 09:46
  • First of all, thanks for this informations. Even if your answere was kind of "flaming". As you can see I sayed **obviously** didnt say thats is NOT implemented. I also never sayed its a 'weird' database!!! Its fine that SB12 was released and thats it is fast... This fact doesnt matters to my point of problem. We use version 7 and yes, i'm sure that v12 has good improvements!... Anyway... i tried your given syntax and it still drops syntax error. Btw. the issue was caused by failed data in db. – Dwza Jan 21 '16 at 13:50