Jump to content

h_itsm_requests_attachments Table


will.good

Recommended Posts

@Keith Stevenson

I am trying to join h_itsm_requests_attachments with h_itsm_requests to get the request status, but i get an error when trying to run this in database direct, works fine without adding the status column and joining the table...any idea where I am going wrong with the join?

SELECT
h_request_id as "Request ID",
h_pk_id as "ID",
h_filename as "Filename",
h_description as "Description",
h_size as "Size",
concat(substring(h_timestamp,9,2),"/",substring(h_timestamp,6,2),"/",substring(h_timestamp,1,4)) as "Date Added",
substring(h_timestamp,12,8) as "Time Added",
h_visibility as "Visibility",
h_status as "Status"
FROM h_itsm_requests_attachments
JOIN h_itsm_requests on h_request_id = h_pk_reference
Where h_size is not null
order by h_size DESC

Link to comment
Share on other sites

On 4/21/2023 at 3:41 PM, will.good said:

@Keith Stevenson

I am trying to join h_itsm_requests_attachments with h_itsm_requests to get the request status, but i get an error when trying to run this in database direct, works fine without adding the status column and joining the table...any idea where I am going wrong with the join?

SELECT
h_request_id as "Request ID",
h_pk_id as "ID",
h_filename as "Filename",
h_description as "Description",
h_size as "Size",
concat(substring(h_timestamp,9,2),"/",substring(h_timestamp,6,2),"/",substring(h_timestamp,1,4)) as "Date Added",
substring(h_timestamp,12,8) as "Time Added",
h_visibility as "Visibility",
h_status as "Status"
FROM h_itsm_requests_attachments
JOIN h_itsm_requests on h_request_id = h_pk_reference
Where h_size is not null
order by h_size DESC

@will.good the tables share the same column names, hence the error. Just need to specify the table name as well as the column e.g. h_itsm_requests.h_description and h_itsm_requests_attachments.h_description. Worth using aliases to make them easier to read like the example below:

 

SELECT 
  att.h_request_id as "Request ID", 
  att.h_pk_id as "ID", 
  att.h_filename as "Filename", 
  att.h_description as "Description", 
  att.h_size as "Size", 
  concat(
    substring(att.h_timestamp, 9, 2), 
    "/", 
    substring(att.h_timestamp, 6, 2), 
    "/", 
    substring(att.h_timestamp, 1, 4)
  ) as "Date Added", 
  substring(att.h_timestamp, 12, 8) as "Time Added", 
  att.h_visibility as "Visibility", 
  req.h_status as "Status" 
FROM 
  h_itsm_requests_attachments att 
  JOIN h_itsm_requests req on att.h_request_id = req.h_pk_reference 
Where 
  att.h_size is not null 
order by 
  att.h_size DESC

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...