X-Press Publishing - Step 23

Hello,

I’m wondering the following syntax within X-Press Publisher project (Step 23):

db.all('SELECT * FROM Artist WHERE Artist.is_currently_employed = 1', (err, artists) => {
})

Why do we need to prepend is_currently_employed = 1 by Artist? Unless I’m missing something, all queries for previous exercices were defined without any prepends so I would just simply write: WHERE is_currently_employed = 1. What is the difference between these 2 queries?

Thank you in advance

@micro0943936965,

Can you please include a link to the exercise?

Thanks!

1 Like

Hi,

Please see below:

https://www.codecademy.com/paths/web-development/tracks/building-a-persistent-api/modules/persistent-api-cumulative-projects/projects/x-press-publishing

Thanks!

@micro0943936965,

In my experience with SQL, you shouldn’t need to specify the table name before the column when you are querying data from one table. You can, but there is no difference between

SELECT * FROM Artist WHERE Artist.is_currently_employed = 1

and

SELECT * FROM Artist WHERE is_currently_employed = 1

if you are only accessing data from the Artist table.

Unless there is some Javascript-specific reason to do it the first way, I think either should be fine in this case. If I were you, I would complete the project using Artist.is_currently_employed and go back and change it to is_currently_employed later to see if it changes anything. I highly suspect there will be no difference.

That was my first thought (there is no difference) but I was not sure. Yes, once I compliete project I will change these values to see if it matters.

Thank you for your help!

I think you write it like that because it’s easier to work with in your editor.
I thought Artist.id didn’t require backticks but just id would have to be written as id.