简体   繁体   English

如何根据列值检查表中是否有任何记录?

[英]How can i check if there is any record in table based on the column values?

I have user_technical_skill table.我有user_technical_skill表。 This table has id, user_id, technical_skill_id and technical_skill_name columns.此表具有 id、user_id、technical_skill_id 和 Technical_skill_name 列。

When i get all data from this table i get response like:当我从该表中获取所有数据时,我得到如下响应:

[
{
"id": "4bf91b41-1925-47ac-ae87-ffbf07d8aa70",
"user_id": "f4484810-28fd-4534-9b90-8f487f16ffaf",
"technical_skill_id": "911511f5-23dd-4bc9-8d9b-ff59ba60497d",
"technical_skill_name": "Java Script"
},
{
"id": "111d187f-3038-4c10-85e9-b928ce40ea33",
"user_id": "3c9ada9e-7242-437a-9aff-9746516945c6",
"technical_skill_id": "a29b0ff8-9487-41d6-9064-2a7de2cabf2e",
"technical_skill_name": "C#"
}
]

when i post new technical skill for some user - for example for user with id f4484810-28fd-4534-9b90-8f487f16ffaf i want to check if there is existing row in this table for him - so to check if this user already have that technical_skill_id当我为某些用户发布新的技术技能时 - 例如,对于 ID 为f4484810-28fd-4534-9b90-8f487f16ffaf的用户,我想检查此表中是否存在针对他的行 - 因此检查该用户是否已经拥有该 Technical_skill_id

how can i do this我怎样才能做到这一点

you can simply do select query with where clause using user_id and technical_skill_id, If it returns any rows then data exists else not.您可以简单地使用 user_id 和 Technical_skill_id 使用 where 子句执行 select 查询,如果它返回任何行,则数据不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM