VBA Excel - MYSQL syntax to show columns correctly

dwsteyl

New Member
Joined
Sep 28, 2017
Messages
20
Hi,

I have one table that contain information on clients for different years. The format of the table looks like this:

ClientCodeYearStatus
C0012019Done
C0012020Done
C0012021Todo
K0012020Done
K0012021Todo
T002
2021Done
W0012021Todo

An ODBC connection is created, and information is taken from the MYSQL database as a recordset, and pasted in Excel. I need to present the data in the following format to make it more readable. The required format:

ClientCode201920202021
C001DoneDoneTodo
K001DoneTodo
T002Done
W001Todo

I assume the SQL would entail some type of JOIN or UNION command referencing the same table a few times in order to get each column separate (and only showing the ClientCode once), but I could not get it working myself. I've searched high and low for example code from other programmers, but could not find any.

Any help would be appreciated!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,922
Messages
6,175,382
Members
452,639
Latest member
RMH2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top