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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:03:28+00:00 2026-06-04T02:03:28+00:00

i have a script to synchronize/output my mysql database with another server. i know

  • 0

i have a script to synchronize/output my mysql database with another server.

i know how to call this SQL query in shell. however, is it possible to convert this script’s output from php to shell script to keep the format shown below (basically values separated by “|” and some URLs)? i need the output in this specific format shown below:

$sql=mysql_query("SELECT a, b, c, d, e FROM tableA LEFT JOIN tableB USING (a)");

while ($res=mysql_fetch_array($sql))
              {
                echo $res['a']."|".$res['b']."|".$res['c']."|http://www.url.com/".$res['e']."/".$res['a'].".php|http://www.url.com/link/".urlencode($res['b'])."\n";
              }   

thanks

  • 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-04T02:03:29+00:00Added an answer on June 4, 2026 at 2:03 am

    You can do all these concatenation with a simple Query passed to mysql from command line :

    mysql -u username -ppassword -D dbname << eof
    SET sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT';
    SELECT a || '|' || b || '|' || c || '|http://www.url.com/' || e || '/' || a || '.php|http://www.url.com/link/' || b AS joinedColum FROM tableA LEFT JOIN tableB USING (a);
    eof
    

    The first SET, set the pipe as concat operator in MySQL so you can join string with SQL standard double pipe instead of using the annoying CONCAT function … After that the result set is a concatenation of strings directly in the SQL query.
    In this way you can execute this command from a bash script without the necessity to have a php interpreter installed …

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

Sidebar

Related Questions

I have a script that connects to SQL Server 2005 default instance. But I'm
I have script.sh that must be run as user2. However, this script can only
I have a 'reference' SQL Server 2005 database that is used as our global
I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then
I have script which allows to display Bing search results. I can call for
I have this script which basically toggles a bgColor class on and off so
I am writing a small script to synchronize 2 MySQL tables ( t1 to
I have table a and table b . (SQL Server 2008) Both tables have
I am working on a sql database project in VS 2010. I know how
I have script with defined class (for instance, Singleton.php). This class implements classic singleton

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.