SQL error: Could not add field ...

Post Reply
iradulovic
Posts: 5
Joined: Thu Aug 04, 2011 6:16 pm

SQL error: Could not add field ...

Post by iradulovic »

Why this SQL:
<sql row 'SELECT a1.anchor anchor, a1.posturl posturl1, a2.posturl posturl2 FROM apidata a1, apidata a2 WHERE a1.anchor = a2.anchor AND a1.posturl <> a2.posturl'></sql>

returns error:
Could not add field a2.$recid, you may have too long table/field names. Try aliasing table names.

This works perfectly:
<sql row 'SELECT a1.anchor anchor, a1.posturl posturl1 FROM apidata a1'></sql>
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

SQL error: Could not add field ...

Post by mark »

What's your texis version? This test works for me:


<sql "create table apidata(anchor varchar(20),posturl varchar(20));"></sql>
<sql "insert into apidata values('a','u1');"></sql>
<sql "insert into apidata values('a','u2');"></sql>
<sql "insert into apidata values('b','u1');"></sql>
<sql "insert into apidata values('b','u2');"></sql>
<sql "SELECT a1.anchor anchor, a1.posturl posturl1, a2.posturl posturl2 FROM apidata a1, apidata a2 WHERE a1.anchor = a2.anchor AND a1.posturl <> a2.posturl;">
$anchor, $posturl1, $posturl2
</sql>
iradulovic
Posts: 5
Joined: Thu Aug 04, 2011 6:16 pm

SQL error: Could not add field ...

Post by iradulovic »

Version: 5.01.1258488718
Your code is working fine, but not with RAM table (and that is what I need):

<sql "create ram table apidata(anchor varchar(20),posturl varchar(20));"></sql>
<sql "insert into apidata values('a','u1');"></sql>
<sql "insert into apidata values('a','u2');"></sql>
<sql "insert into apidata values('b','u1');"></sql>
<sql "insert into apidata values('b','u2');"></sql>
<sql "SELECT a1.anchor anchor, a1.posturl posturl1, a2.posturl posturl2 FROM apidata a1, apidata a2 WHERE a1.anchor = a2.anchor AND a1.posturl <> a2.posturl;">
$anchor, $posturl1, $posturl2
</sql>
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

SQL error: Could not add field ...

Post by mark »

Yes, I see. I can't think of any workaround.

Perhaps if you describe what you're trying to accomplish someone can think of another way to do it.
iradulovic
Posts: 5
Joined: Thu Aug 04, 2011 6:16 pm

SQL error: Could not add field ...

Post by iradulovic »

Thank you; I found another way to do it.
iradulovic
Posts: 5
Joined: Thu Aug 04, 2011 6:16 pm

SQL error: Could not add field ...

Post by iradulovic »

I found one more ram tables bug:

<sql "create ram table apidata(anchor varchar(20),posturl varchar(20));"></sql>
<sql "insert into apidata values('a','u1');"></sql>
<sql "insert into apidata values('a','u2');"></sql>
<sql "insert into apidata values('b','u1');"></sql>
<sql "insert into apidata values('b','u2');"></sql>
<sql "insert into apidata values('b','u5');"></sql>
<sql "insert into apidata values('c','u2');"></sql>
<sql "insert into apidata values('c','u5');"></sql>
<sql "insert into apidata values('d','u1');"></sql>
<sql "insert into apidata values('e','u3');"></sql>
<sql "SELECT DISTINCT anchor FROM apidata">
$anchor
<sql "SELECT posturl FROM apidata WHERE anchor=$anchor">
$posturl
</sql>
</sql>
<sql "drop table apidata"></sql>
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

SQL error: Could not add field ...

Post by mark »

<sql "SELECT DISTINCT anchor FROM apidata">
</sql>
<loop $anchor>
$anchor
<sql "SELECT posturl FROM apidata WHERE anchor=$anchor">
$posturl
</sql>
</loop>
iradulovic
Posts: 5
Joined: Thu Aug 04, 2011 6:16 pm

SQL error: Could not add field ...

Post by iradulovic »

Thank you
Post Reply