Skip to content

Tag: sql

sql join without intermediate table (old database)

I’m working with a really old database and I’d like to do a simple join. Unfortunately, there is no intermediate table and it’s not possible to implement it in the near future (I know it’s really bad). The tables look like this: Expected result (for tbl_1.id = 1) How can I achieve that…

Compare rows in one table with MySQL

I tried to compare rows in one table that I have. The table is like this: table I have 3 rows for comparing, and they had tp 1,2,3 for each one with the same fid and different id. The question is, how can I compare three of them to return? For example, more explanation For example, if ct of the

PostgreSQL – How to format an int as an hexa

What’s a short/simplest way of formatting an int to an hexa, with leading zeroes? For example I need to format: My query needs many of these conversions I would appreciate a short piece of code instead of a verbose one. Just need to deal with positive numbers. Answer I’m not sure it’s the sh…

SQL add a * to front and back

Need to add a * to the front and back of the results in order to be able to export it via report builder and use barcodes fonts. Example *1234* My query is My result is I am looking for Answer Use concat():

SQL remove leading zeros

I am unable to remove the leading zeros from a column. In this case my SQL query is The result is I am looking for this result. Answer Use the floor() function: Why are you storing these values as strings in the first place? You should be storing numbers as numbers. And if they are numbers, you should not be