How to export and import a .sql file from command line with options? [duplicate]

Type the following command to import sql data file: $ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql In this example, import ‘data.sql’ file into ‘blog’ database using vivek as username: $ mysql -u vivek -p -h localhost blog < data.sql If you have a dedicated database server, replace localhost hostname with with actual … Read more

Oracle Database Link – MySQL Equivalent?

I can think of four possible workarounds for your scenario: use fully-qualified-table-names when querying for the external table. MySQL supports the dbname.tablename-syntax to access tables outside the current database scope. This requires that the currently connected user has the appropriate rights to read from the requested table in another physical db. if your external database … Read more

How do you extract a numerical value from a string in a MySQL query?

This function does the job of only returning the digits 0-9 from the string, which does the job nicely to solve your issue, regardless of what prefixes or postfixes you have. http://www.artfulsoftware.com/infotree/queries.php?&bw=1280#815 Copied here for reference: SET GLOBAL log_bin_trust_function_creators=1; DROP FUNCTION IF EXISTS digits; DELIMITER | CREATE FUNCTION digits( str CHAR(32) ) RETURNS CHAR(32) BEGIN … Read more

CROSS/OUTER APPLY in MySQL

Your closest direct approximation is a join with a correlated sub-query as the predicate. SELECT ORD.ID ,ORD.NAME ,ORD.DATE ,ORD_HISTORY.VALUE FROM ORD INNER JOIN ORD_HISTORY ON ORD_HISTORY.<PRIMARY_KEY> = (SELECT ORD_HISTORY.<PRIMARY_KEY> FROM ORD_HISTORY WHERE ORD.ID = ORD_HISTORY.ID AND ORD.DATE <= ORD_HISTORY.DATE ORDER BY ORD_HISTORY.DATE DESC LIMIT 1 ) In your case, however, you only need one field … Read more