Why is my query not working?

vitaminchik 486 Reputation points
2023-04-22T13:03:41.02+00:00

User's image

my request: SELECT naimenovaniye FROM TableOborudovaniye WHERE specialnost= 'М' User's image

I want to get a list of equipment names where specialnost=M

SQL Server | Other
{count} votes

Answer accepted by question author
  1. Lucas Sousa da Silva 75 Reputation points
    2023-04-23T23:28:00.6666667+00:00

    Try to do like this: SELECT naimenovaniye FROM TableOborudovaniye WHERE specialnost like '%М%'Doing like this you ensure that any space or character misclicked will be out.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-04-24T07:27:20.7266667+00:00

    Hi @vitaminchik

    Based on the image information you provided, I tried to create a table and insert test data.

    create table dbo.TableOborudovaniye(
       ID int identity(1,1) not null,
       specialnost nchar(10) not null,
       naimenovaniye NVARCHAR(MAX) not null,
       chastota int not null,
       kratkoe_opisaniye NVARCHAR(MAX) null,
       PRIMARY KEY CLUSTERED(ID ASC)
       );
     
     insert into TableOborudovaniye values
     ('M','Juki DDL-9000B-SS',1,'AS'),
     ('C','Typical GN-795',5,'ad');
    

    Run the same query statement and it can get the result.

    User's image

    Can you provide your complete table creation statement and some test data? This helps to solve the problem.

    Best regards,

    Percy Tang

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.