Can somebody suggest me what is wrong with this query? [closed] - sql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
select met.metno , eps.sn , el.ed
from el
inner join met on eps.sn=met.sn
inner join eps
on el.epid=eps.epid
where el.etid=1002
and el.ed>'2017-01-03'
and el.ed<'2018-07-05'

You have an additional inner join after the where clause. Do the joins first (FROM) then the WHERE

Related

Using SQL BETWEEN [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 months ago.
Improve this question
Please help me fix this error.
SELECT
*
FROM activity_log_admins
WHERE query_date BETWEEN 4th-June-2022 AND 10th-June-2022
But am receiving this error.
#1054 - Unknown column '4th' in 'where clause'
Assuming query_date is a type of datetime, Try
SELECT
*
FROM activity_log_admins
WHERE query_date BETWEEN '2202-06-04' AND '2202-06-10'

Postgresql missing FROM-entry for table [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have 2 tables
messages
respondents
and I'm trying to join them using a simple inner join query
SELECT
Message.content,
Message.created_at,
Respondent.name
FROM
MESSAGES
INNER JOIN RESPONDENTS ON Message.respondent_id = Respondent.id;
and I'm getting this error:
ERROR: missing FROM-clause entry for table "message"
LINE 1: ...dent.name FROM MESSAGES INNER JOIN RESPONDENTS ON Message.re...
Can anyone help me out??
There are two typos in your query. Try this - assuming your tables are called respondents and messages:
SELECT
messages.content, messages.created_at, respondents.name
FROM messages
INNER JOIN respondents ON messages.respondent_id = respondents.id;

How to get exact result from charindex? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
select *
from table_name
where charindex(dest_mail,'abc#mail.com') >0
In the above query dest_mail is a column, but there is another entry in the table, which is 'bc#mail.com'. When I try to execute the above query, I'm getting two results
1.abc#mail.com
2.bc#mail.com
How to get exact 'abc#mail.com'?
Have you considered =?
where dest_mail = 'abc#mail.com'
Also, charindex() is not very colloquial SQL for this purpose; = is a built-in standard operator (charindex() is not standard). And a bonus to = is that it allows the optimizer to take advantage of indexes and partitions.

ORA-00918 Column ambiguously defined [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
SELECT INDIVIDUAL.INV_FNAME,
INDIVIDUAL.INV_LNAME,
INDIVIDUAL.INV_IC_NUM,
CUSTOMER.MEMBER_LEVEL,
CUSTOMER.MEMBER_POINT_BALANCE,
CUSTOMER.MEMBER_DISCOUNT_RATE,
PROGRAM_USER.USER_CONTACT_NUM,
PROGRAM_USER.USER_ADDRESS,
PROGRAM_USER.USER_CITY,
PROGRAM_USER.USER_STATE,
PROGRAM_USER.USER_ZIP_CODE,
PROGRAM_USER.USER_COUNTRY,
PROGRAM_USER.USER_EMAIL
FROM PROGRAM_USER,CUSTOMER,INDIVIDUAL
WHERE USER_ID = ‘san’;
In your query only USER_ID column in the where condition is not specified with a table name. I guess USER_ID is there in multiple table. Try the where condition with proper table name
SELECT INDIVIDUAL.INV_FNAME,
INDIVIDUAL.INV_LNAME,
INDIVIDUAL.INV_IC_NUM,
CUSTOMER.MEMBER_LEVEL,
CUSTOMER.MEMBER_POINT_BALANCE,
CUSTOMER.MEMBER_DISCOUNT_RATE,
PROGRAM_USER.USER_CONTACT_NUM,
PROGRAM_USER.USER_ADDRESS,
PROGRAM_USER.USER_CITY,
PROGRAM_USER.USER_STATE,
PROGRAM_USER.USER_ZIP_CODE,
PROGRAM_USER.USER_COUNTRY,
PROGRAM_USER.USER_EMAIL
FROM PROGRAM_USER,CUSTOMER,INDIVIDUAL
WHERE PROGRAM_USER.USER_ID = ‘san’;
Also like #HoneyBadger comment you need to specify the join between the tables

Incorrect syntax near '.\'. in sql [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
When I ran the query I am getting incorrect syntax error. can any one help me to fix it?
SELECT
si.SoftwareImage as ImagePLName,
SUBSTRING(si.SoftwareImage, 0, CHARINDEX(\'.\',si.SoftwareImage)),
sib.SoftwareImageBuild as BuildID
FROM
v000001.SoftwareProductBuilds spb
JOIN
v000001.SoftwareProductBuildSoftwareImageBuilds spbisib ON spbisib.SoftwareProductBuildId = spb.SoftwareProductBuildId
JOIN
v000001.SoftwareImageBuilds sib ON sib.SoftwareImageBuildId = spbisib.SoftwareImageBuildId
JOIN
v000001.SoftwareImages si ON si.SoftwareImageId = sib.SoftwareImageId
WHERE
spb.SoftwareProductBuild = '123456'
It should be:
CHARINDEX('.\',si.SoftwareImage)
Documentation to CHARINDEX for SQL Server
Documentation to CHARINDEX for Sybase.