# Help - MYSQL and Swi Prolog

**URL:** <https://swi-prolog.discourse.group/t/help-mysql-and-swi-prolog/2618>\
**Category:** Help!\
**Tags:** how-to\
**Created:** [July 9, 2020, 3:41am UTC](https://swi-prolog.discourse.group/t/help-mysql-and-swi-prolog/2618 "2020-07-09T03:41:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [July 9, 2020, 9:58am UTC](https://swi-prolog.discourse.group/t/help-mysql-and-swi-prolog/2618/2 "2020-07-09T09:58:50Z")

</div>

It looks like the ODBC connection is working based on

```prolog
ERROR: ODBC: State 42522: [MySQL][ODBC 8.0(w) Driver][mysqld-5.7.24]Unknown column '12' in 'field list'

```

but as I have not used MySQL with ODBC I would start from the ground up in resolving this problem.

1. Check the ODBC configuration using iusql.

When I created a [Wiki for using ODBC with PostgreSQL](https://swi-prolog.discourse.group/t/swi-prolog-connecting-to-postgresql-via-odbc/2404) it starts with checking the ODBC configuration using [iusql](https://swi-prolog.discourse.group/t/swi-prolog-connecting-to-postgresql-via-odbc/2404#7-test-odbc-settings-using-iusql-2). You should be able to do the same but instead using your ODBC configuration. If you are not on Linux then you should find a similar tool.

1. Check ODBC connection using the SWI-Prolog DSN configuration.

The wiki also has some [simple test cases](https://swi-prolog.discourse.group/t/swi-prolog-connecting-to-postgresql-via-odbc/2404#simple-test-cases). You should be able to create similar queries and get similar results using MySQL.

1. Check your Prolog quires without using MySQL.

2. Add some [guard statements](https://en.wikipedia.org/wiki/Guard_(computer_science)) using must\_be/2 for the quires connecting to MySQL, e.g.

```prolog
insertar_registros(X,Y) :-
   must_be(ground,X),
   must_be(ground,Y),
   odbc_query( ... ),
   ...

```

There is not much more help I can give you than this without installing MySQL which is not on my task list for the day.

Also please translate the error messages in images into text as it makes it better for others seeking help on the same problem and makes it easier for us helping you to read the full error message. 😀

---

_[View the full topic](https://swi-prolog.discourse.group/t/help-mysql-and-swi-prolog/2618)._
