Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to query data #7

Open
pkasson opened this issue Nov 28, 2024 · 3 comments
Open

How to query data #7

pkasson opened this issue Nov 28, 2024 · 3 comments

Comments

@pkasson
Copy link

pkasson commented Nov 28, 2024

I can query a table which has a numeric column ok, but when I query a table with a column that is string, it fails with a sql error:

This query works, on a numeric column:

select _name, age, sex from animals where age > 3

it returns the proper results .. but this fails:

select _name, age, sex from animals where sex = “M”

it returns the following error:

"Binder Error: Referenced column "“M”" not found in FROM clause!\nCandidate bindings: "animals.age"\nLINE 1: ...ame, age, sex from animals where sex = “M”\n

@stensoosaar
Copy link

try 'M' not "M"

@pkasson
Copy link
Author

pkasson commented Dec 5, 2024

I tried that as well ...

select _name, age, sex from animals where sex = ‘M’

Referenced column "‘M’" not found in FROM clause!\nCandidate bindings: "animals.age"\nLINE 2: from animals where sex = ‘M’\n

@stensoosaar
Copy link

You should check your string formatting.

let query = try connection.query("""
	select
	       _name,
		age,
		sex
	from animals
	where sex = 'M';
""")

gives you

<ResultSet: { chunks: 0; rows: 0; columns: 3; layout: (
	_name DATABASETYPE.VARCHAR,
	age DATABASETYPE.INTEGER,
	sex DATABASETYPE.VARCHAR
);>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants