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

  • Home
  • SEARCH
  • 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 7983411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:56:57+00:00 2026-06-04T10:56:57+00:00

Evening, I’m currently running this query: SELECT `id`, `type`, `controller` FROM `urls` WHERE `url`

  • 0

Evening,

I’m currently running this query:

SELECT `id`, `type`, `controller` FROM `urls` WHERE `url` = :url;
UPDATE `urls` SET `views` = `views` + 1 WHERE `url` = :url;

I run this when a page is loaded and it increments the views column by 1. However, I’m interested to know if there is a way (maybe using something like a trigger) that the view column could be incremented automatically.

  • 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-04T10:56:59+00:00Added an answer on June 4, 2026 at 10:56 am

    I can’t find an exact duplicate but Syntax for "RETURNING" clause in Mysql PDO and Mysql returning clause equivalent give you the answer you need.

    MySQL does not have an equivalent of Oracle and PostgreSQLs returning into clause. You’ll have to use two separate statements.


    If you’re expecting to do a lot of updates it might (conditional, it might not) be better to keep the number of views in a separate table, especially as you’re not returning the view count in your query. Something like the following:

    insert into url_views values(url);
    
    select `id`, `type`, `controller` from `urls` where `url` = :url;
    

    and then if you need the number of views:

    select count(*)
      from url_views
    where url = :url
    

    or use MySQLs insert ... select syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Evening, I am currently handling PDO exceptions like this: try{ $db = Db::connect(); $query
This evening I noticed a brute force attack attempt from the same IP address
Evening folks!! Stuck with this rather dull problem. I have deployed my website on
Good evening, In my app that I'm currently developing, I have a class that
Good evening. For a project, I have to create a system. In this system,
Good evening fellow coders, and thank you in advance for any help/attention. This is
Good evening StackOverflow This time I'm fighting with a ListView Containing TextViews. I add
Yesterday evening I left the office with a running Java program written by me.
Good Evening, I'm building a website which will will look something like this: So
Good evening :-)! I have this code to use Drag & Drop method for

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.