Skip to content

Tag: mysql

Creating JDBC Application

I have this piece of code: but I have this error: Answer Since you commented out your print statement, your loop is now closing the connection (and all of its dependent resources). Your code, without the commented out line:

MySQL join dataset on at least X items

My question in a SQL Fiddle. How can I join all elements in table A with all elements in table B via a many-to-many mapping table, even if no relationship exists? My LEFT JOIN solution isn’t giving the results I expect. Details: Given these tables: And this seed data: I need a report like this: The quer…

SQL pivot the column values

Problem Statement: Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Note: Print NULL when there are no more names corresponding to…

Timecard report that shows hours worked every day, even when its zero

############################################ The above query produces this: query results What I want is for the work_date column to show every date in the month. If someone doesn’t work then WO#, act_hours, phase#, and trans_no would all be null but the work_date field, shop, and employee # would still…

Find the max value in the last digit

I am using MySQL 5.5. I am facing a problem on how to find the max value in the last digit. For example below the table, I want to get the max value is detected the last digit. The result should be …