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 840589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:38:56+00:00 2026-05-15T05:38:56+00:00

How can I translate this 2 queries in postgresql ? : CREATE TABLE `example`

  • 0

How can I translate this 2 queries in postgresql ? :

CREATE TABLE  `example` ( 
  `id` int(10) unsigned NOT NULL auto_increment,    
  `from` varchar(255) NOT NULL default '0',    
  `message` text NOT NULL,    
  `lastactivity` timestamp NULL default '0000-00-00 00:00:00',    
  `read` int(10) unsigned NOT NULL,    
  PRIMARY KEY  (`id`),    
  KEY `from` (`from`)    
) DEFAULT CHARSET=utf8;

Query:

SELECT *
FROM table_1
LEFT OUTER JOIN table_2 ON ( table_1.id = table_2.id ) 
WHERE (table_1.lastactivity > NOW()-100);
  • 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-05-15T05:38:57+00:00Added an answer on May 15, 2026 at 5:38 am

    Use:

       SELECT *
         FROM table_1 t1
    LEFT JOIN table_2 t2 ON t2.id = t1.id
        WHERE t1.lastactivity > CURRENT_TIMESTAMP - INTERVAL '100 days'
    

    CURRENT_TIMESTAMP is ANSI standard, and works on Oracle, MySQL, Postgres, SQL Server…

    Here’s the CREATE table statement converted:

    CREATE TABLE example (
      id INTEGER PRIMARY KEY, 
      "from" VARCHAR(255) NOT NULL DEFAULT '0',
      message text NOT NULL,
      lastactivity timestamp DEFAULT NULL,
      read INTEGER NOT NULL
    )
    

    I can’t find anything about Postgres allowing character sets per table, only that you would set UTF8 support using the UNICODE keyword when creating the database:

    CREATE DATABASE your_db WITH  ENCODING 'UNICODE';
    $ createdb -E UNICODE your_db --CLI version
    

    Postgre, like Oracle, uses sequences for AUTO_INCREMENT behavior:

    CREATE SEQUENCE example_seq START 1;
    

    Then, you need to call NEXTVAL([your sequence name]) in the insert statement to populate the primary key:

    INSERT INTO example (id) VALUES (NEXTVAL(example_seq))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

RailsCast #326 ActiveAttr explains how to create table-less models. How can one translate the
how i can translate this code into razor syntax: <% for (int i =
Who can help me to translate this XML Schema pattern [0-9]+-([0-9]|K) to java regular
I found the solution for this question in C# , but I can't translate
How can I translate whole URI in routes using I18n? Example: (CZ URI =>
can you translate this Rails code for MySQL: def Customer.find_by_key(key) Customer.find(:all, :conditions => pre_name
how can I translate this to Linq to SQL I want to get all
I am using window.addEventListener(touchstart, function(ev){ console.log(ev.touches); // good }); How can I translate this
I have a basic datatable, it can be completely generic for this example, except
Given that the Windows API function GetGlyphIndices() can translate a 2 byte UNICODE char

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.