Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:37:33+00:00 2026-06-09T16:37:33+00:00

I am using a select statement with a join to try and insert a

  • 0

I am using a select statement with a join to try and insert a column into a mySQL database table.

My code:

insert into trips_last_arrival_time(start_time)
select min_arrival_time.start_time
from min_arrival_time 
            inner join trips_last_arrival_time 
            on min_arrival_time.trip_id = trips_last_arrival_time.trip_id;

I am getting :

[Err] 1364 - Field 'trip_id' doesn't have a default value
trip_id is the primary key of both tables. 

The start_time column is blank, not filled with nulls.

I’ve tried an UPDATE clause too

update trips_last_arrival_time
set trips_last_arrival_time.start_time  = (
select start_time from min_arrival_time )
where exists(
select trip_id from trips_last_arrival_time
where trips_last_arrival_time.trip_id = min_arrival_time.trip_id)

And there’s a column trip_id in the table min_arrival_time (in fact it’s the primary key of both tables!)
But this UPDATE clause gives me:

[Err] 1054 - Unknown column 'min_arrival_time.trip_id' in 'where clause'

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:37:34+00:00Added an answer on June 9, 2026 at 4:37 pm

    You are trying to insert on an existing row (it exists because you have tried to SELECT it). Regardless of whether trip_id has a default value, this is not the correct operation. You need to do an UPDATE.

    For your update, I’m pretty sure you need to do this:

    UPDATE trips_last_arrival_time AS t, min_arrival_time AS m
        SET t.start_time = m.start_time
        WHERE t.trip_id = m.trip_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a SELECT statement in MS SQL 2005 TSQL, and no source table, just
I'm currently using a select statement with one column as DATEPART(hh, CallTime) AS Hour
I am using an IF statement in my mySQL SELECT statement and depending on
I have a MySQL database holding hierarchical data using the Closure Table method. A
Ho to do this? What query can be written by using select statement where
I am executing the select statement with using jdbc sybase driver ( jconn3 ).
I am trying to write a custom select statement in Hibernate using the getHibernateTemplate()
I'm using this statement in SQLServer and it works fine: SELECT TOP 1000 *
I am using the following statement; SELECT RESV_ID, BOOKING_CUS_ID, ACC_ID, (SELECT F.FLI_PRICE FROM FLIGHT
I am using to write a select query and the value for like statement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.