有没有办法在SQL列中单独输出数据?

时间:2017-12-10 02:26:52

标签: sql joomla

因此,我正在使用一个旧的joomla网站并尝试仅导出有用的数据,我找到了一种非常好的方式来完成我想要做的事情。

因此,对于我想要访问的列,图像,即使没有有用的信息输入,joomla会自动填充以下内容:

{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""} 

我理想情况下只想搜索image_fulltext值不为空的字段,并且只获取字段的值。

我最初的想法就是这个hacky片段至少找到相关的行。

SELECT id, images FROM `JOOMLAPREFIX_content` WHERE images !='{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}'

这让我获得了相关的行,但它也为我提供了比我想要的更多的信息。 (第一个建议的解决方案,虽然更少" hackey"查询,得到了相同的结果,正如您在SQL片段中看到的那样。)

Id          Images

7           {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"images\/featuredimage1832014.jpg","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}   

在这一行的情况下,有没有办法只定位image_fulltext的值:" images / featuredimage1832014.jpg"?

SQL Fiddle

1 个答案:

答案 0 :(得分:0)

试试这个:

SELECT id, images FROM `JOOMLAPREFIX_content` WHERE images NOT LIKE '%"image_fulltext":""%'