如何从Mysql中获取第一条路径? [英] How to get only the first path from Mysql?

查看:101
本文介绍了如何从Mysql中获取第一条路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,看看我是否可以解释。

我的数据库中有一个查询,它插入了输入对象的id。结果是在我用来显示内容的字符串中。在其中一个sql表中,有图像的路径名。一个id最多可以分配3个图像,这些图像提供3个路径名。但这里有捕获,我只想显示第一个路径名。我的查询如下所示:

Ok, let see if I can explain.
I have a query from my db which inserts id of the inputted objects. The result is in a string which I use to show the content. In one of the sql tables, there are path names to images. One id can have up to 3 images assigned which gives 3 path names. But here is the catch, I only want to display the first path name. My query looks like this:

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号

推荐答案

查询后可以执行以下操作吗?您的数据库,以便我们可以看到正在存储的数据:

Can you please do the following, after you have queried your database so we can see what data is being stored:

展开 | 选择 | Wrap | Line数字


感谢您的建议和回复。 VAR DUMP输出:
Thanks for your suggestions and reply. The VAR DUMP outputs this:
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


好吧,在SQL查询中,你可以 LIMIT 1 ,或者您可以访问第一个元素你的数组:
Well, in your SQL query, you could LIMIT 1, or you could access the first element of your array:


这篇关于如何从Mysql中获取第一条路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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