user974703
user974703

Reputation: 1653

Select rows from column with same value

I have a table of book authors, and am trying to get a query result of books by a certain author.

Something like

SELECT * FROM mytable WHERE authors = Carl Sagan

I need all of the columns for each row that matches.

Any help would be appreciated, I'm new to SQL.

Thanks!

Upvotes: 0

Views: 702

Answers (3)

Ryan Kazinec
Ryan Kazinec

Reputation: 51

Just to clarify, Assumptions: 1.) Carl Sagan authored more than one item in this table. 2.) You want to return all of the occurrences of Carl Sagan.

Original: SELECT * FROM mytable WHERE authors = Carl Sagan

Should Be: SELECT * FROM mytable WHERE authors = 'Carl Sagan'

FYI, I use HeidiSQL to test queries. Let me know if that helps.

Upvotes: 3

John Woo
John Woo

Reputation: 263933

Your question seems unclear to me, but modify your query by putting a single quote

SELECT * FROM mytable WHERE authors = 'Carl Sagan'

Upvotes: 1

QuantumMechanic
QuantumMechanic

Reputation: 13946

You have the query correct except that you need to have the text you're comparing to delimited as a string:

SELECT * FROM mytable WHERE authors='Carl Sagan'

Upvotes: 2

Related Questions