# Wild card in SelectSQL

**URL:** <https://forum.xojo.com/t/wild-card-in-selectsql/66253>\
**Category:** Databases\
**Created:** [October 25, 2021, 5:56pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253 "2021-10-25T17:56:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dale\_Arends](https://forum.xojo.com/user_avatar/forum.xojo.com/dale_arends/32/442_2.png) [@Dale\_Arends](https://forum.xojo.com/u/Dale_Arends)\
**Post date:** [October 25, 2021, 5:56pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/1 "2021-10-25T17:56:57Z")

</div>

I am getting a database (syntax) error on the following statements:

```auto
sql = "SELECT HashValue FROM ?"
rs = theDB.SelectSQL (sql, tablename)

```

The error message is `near "?": syntax error`

Is using a wildcard for the tablename legal?

Data: Windows 10, Xojo 2021r2, Sqlite

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [October 25, 2021, 6:06pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/2 "2021-10-25T18:06:56Z")

</div>

You could just do:

```auto
sql = "select HashValue from " + tablename
rs = theDB.SelectSQL (sql)

```

How is tablename declared? And does the sql match the schema?

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [October 25, 2021, 6:30pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/3 "2021-10-25T18:30:34Z")

</div>

No, it’s not legal there. You’ll need to do something like `SELECT * FROM “”“ + TableName.ReplaceAll(“”””, “”””””) + “””;”` instead.

---

<div class="post-metadata">

**Author:** ![Dale\_Arends](https://forum.xojo.com/user_avatar/forum.xojo.com/dale_arends/32/442_2.png) [@Dale\_Arends](https://forum.xojo.com/u/Dale_Arends)\
**Post date:** [October 25, 2021, 6:40pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/4 "2021-10-25T18:40:18Z")

</div>

That’s what I thought. 🙁 I was hoping to avoid string concatenation but that’ll have to be the route I’ll take.

---

<div class="post-metadata">

**Author:** ![Dale\_Arends](https://forum.xojo.com/user_avatar/forum.xojo.com/dale_arends/32/442_2.png) [@Dale\_Arends](https://forum.xojo.com/u/Dale_Arends)\
**Post date:** [October 25, 2021, 6:43pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/5 "2021-10-25T18:43:08Z")

</div>

Tablename is a string and, yes, the sql matches the schema.

I use wildcards frequently in various WHERE clauses but having it in the FROM clause would make things a bit easier for me. Ah, well…

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [October 25, 2021, 7:54pm UTC](https://forum.xojo.com/t/wild-card-in-selectsql/66253/6 "2021-10-25T19:54:08Z")

</div>

I’m not saying you can’t do it - haven’t tested that.
