Skip to content

Tag: mysql

Select integer column as corresponding letter of the alphabet

I have an int column that contains values no larger than about 20. I want to select as its corresponding upper case letter of the alphabet: I don’t care what happens after Z because the column doesn’t contain larger values. Is there a simple way to do this with a SQL query, to convert to a single-…

How to convert Buffer to base64 image in Node js

I am getting data from my SQL database like this: How can I convert result to a base64 image in Node.js? For Example: ‘data:image/png;base64,iVBORw0KGgoAAAANS’ Answer Since you’re receiving a Buffer back as output, Buffer.toString(‘base64’) will convert the raw binary data in the buffe…

Tricky MySQL view

I am finding it very difficult to create a view in MySQL, and hope someone could help me out. This is the schema of my db: This database collects a series of football games and many characteristics for each one, as well as all the teams and the seasons. Thanks to this view (https://stackoverflow.com/a/7079444…

Combine Date and Time Fields and Order By DateTime Field

I would like to combine the date and time for meta values performance_date_1 and performance_time_1 and then sort by this new DATETIME value. Here is my SQL query so far, but no luck. Query SQL: SELECT TIMESTAMP(performance_date_1, performance_time_1) as DateTimeTS FROM test ORDER BY DateTimeTS; Because of ho…

MYSQL Query select only first record of foreign key

First of all, I am pretty new to MySQL. I am currently stuck with the following query. I have several tables that have relations between each other. Every user can create multiple projects. Every project can have one attachment, multiple attachments (images) or no attachment at all. Every project only has one…