# SQL error

**URL:** <https://forum.servoy.com/t/sql-error/3307>\
**Category:** Classic Servoy\
**Created:** [December 20, 2004, 4:21pm UTC](https://forum.servoy.com/t/sql-error/3307 "2004-12-20T16:21:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [December 20, 2004, 4:21pm UTC](https://forum.servoy.com/t/sql-error/3307/1 "2004-12-20T16:21:38Z")

</div>

In the example below I want SQL to present me with all records where the accountmanager column equals “maarten”. Instead I’m being given an error that SQL can’t find a column called “maarten”.

Note I’m deliberately setting up to search by the contents of a variable derived from an array. I’ve broken a larger problem so I can debug in parts. A number of contributors to this forum have indicated the way to query sql for instances of a column matching the contents of a variable is the following. Hard coding for '“maarten” also yields the same error.

Test solution called "sqlissue1’, using crm server and companies table (form also called companies)

```auto
var a1 = new Array(3);
a1[0] = 'maarten';
a1[1] = 't.banks';
a1[2] = 's.james';
var a1target = a1[0];
var maxReturedRows = 10; 
var query = 'select companiesid from companies where accountmanager = ' + a1target;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows);
controller.loadRecords(dataset);

```

Error message is:

> dataset com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -143: Column ‘maarten’ not found ASA Error -143: Column ‘maarten’ not found

Servoy Developer  
Version R2 2.1.2-build 315  
Java version 1.4.2\_05-b04 (Windows XP)

What am I missing?

---

<div class="post-metadata">

**Author:** ![rkrservoy](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rkrservoy](https://forum.servoy.com/u/rkrservoy)\
**Post date:** [December 20, 2004, 4:35pm UTC](https://forum.servoy.com/t/sql-error/3307/2 "2004-12-20T16:35:19Z")

</div>

var SQLquery = "SELECT companiesid FROM companies WHERE accountmanager = ’ " + a1target + "’ " ;

The quotes are important

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [December 20, 2004, 4:40pm UTC](https://forum.servoy.com/t/sql-error/3307/3 "2004-12-20T16:40:58Z")

</div>

Thanks, that worked! That’s a lot of quotation marks, obviously necessary.

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [December 20, 2004, 7:11pm UTC](https://forum.servoy.com/t/sql-error/3307/4 "2004-12-20T19:11:56Z")

</div>

> Morley:  
> Thanks, that worked! That’s a lot of quotation marks, obviously necessary.

A little tip: never test your SQL in the method editor.  
Use a tool like Interactive SQL or similar: if your code works there and you’re getting errors in Servoy, you can be pretty sure is something related to quotes or typos.
