可以解析查询吗? [英] Is parsing query possible?

查看:88
本文介绍了可以解析查询吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个表,用于将值存储为键,并将值存储在文本字段中(例如0,male \ n 1,female).我只想根据密钥检索男性或女性文本.我要执行的是mySql,而不是稍后在网站中使用php.因此,基本上我有另一个存储性别(0或1)的表,并且我希望查询引用包含0,male \的表. n 1,女性,并根据我给出的值(0或1)获得适当的标签(男性或女性).这可能吗?我正在使用MySQL

Hello I have a table which stores values as key and value in a text field (e.g 0,male \n 1,female). I want to just want to retrieve the male or female texts according to the key. I want to do this is mySql opposed to using php in the website to do it later.So essentially I have another table that stores the sex ( 0 or 1) and I want the query to reference to the table that contains 0,male \n 1,female and get the appropriate label(male or female) based on the value I give (0 or 1). Is this possible? I am using MySQL

推荐答案

尝试遵循查询

try follow query

select case when [columnname]=0 then 'Male' else 'Female' end from [tablename]



如果这是您的解决方案,请回答.不要忘记对解决方案进行评分.

谢谢



make it answer if this is your solution. dont forget to rate the solution.

thanks


这篇关于可以解析查询吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆