在 MySQL SELECT 查询中生成重复响应
我正在应用程序中使用报告编写功能来生成条形码产品标签。
报告编写系统允许我使用 MySQL SELECT 语句从数据库中获取所需的信息,并将其呈现给格式化报告的 Jasper Reports JRXML 文件。
如果我想为 SELECT 语句从数据库返回的每件产品生成一个条形码标签,这种方法就很有效。不过,我想为每个产品标签制作五十份。
如果我能够访问代码就很容易了,但我能更改的只是 SQL 语句。
谁能建议一种方法,让 MySQL SELECT 语句为在产品表中找到的每条记录返回 50 个相同的结果?
感谢您的任何帮助。
I am using the report writing functionality within an application to generate barcode product labels.
The report writing system allows me to use a MySQL SELECT statement to get the information I need from our database and present it to a Jasper Reports JRXML file that formats the report.
This works fine if I want to produce one barcode label for each product returned from the database by my SELECT statement. However I want to produce fifty copies of each product label.
Easy enough if I had access to the code, but all I can change is the SQL statement.
Can anyone suggest a way in which I can get a MySQL SELECT statement to return 50 identical results for each record it finds in the products table?
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只是有一个丑陋的解决方案,假设你可以修改模式:创建一个包含 50 条记录的虚拟表并将其加入到你的 sql 查询中,如下所示: select * from products, dummyWith50Records
我几乎羞于写这样的东西,但它应该有效...希望有人有更好的解决方案。
I just have an ugly solution, assuming you can modify the schema: create a dummy table containing 50 records and join it in your sql queries like this: select * from products, dummyWith50Records
I'm almost shameful to write something like that, but it should work ... Hopefully someone has a better solution.
针对动态无用信息表的交叉连接,其中包含您想要的重复行数。
在本例中,我在
table
中得到每个符合条件的行的 5 个重复项。它并不漂亮,但它可以工作,并且不需要创建一个真实表。
A cross join against a on-the-fly table of dud information with as many rows as you want duplicates.
In this case, I'm getting 5 duplicates of every qualifying row in
table
.It's not pretty, but it works, and it doesn't require creating a real table.
我能够理解你的问题...但是举个例子对我来说会更有帮助...
我想我在我的一个应用程序中做了同样的事情
I am able to understand your problem... But it would be more helpful for me with an example...
I think I was doing the same thing in one of my application