SQL syntax debug: Difference between revisions

Jump to navigation Jump to search
m
Line 20: Line 20:
* [http://www.dpriver.com/pp/sqlformat.htm Instant SQL Formatter]
* [http://www.dpriver.com/pp/sqlformat.htm Instant SQL Formatter]


== Approach 4: Compare the row counts between source table with parsed table ==
== Approach 4: Compare the row counts between source table with target table ==
 
The {{kbd | key=<nowiki>`source_table`</nowiki>}} contains raw data. Another {{kbd | key=<nowiki>`target_table`</nowiki>}} contains parsed data.
<pre>
<pre>
SELECT @timer := CURRENT_TIMESTAMP();
SELECT @timer := CURRENT_TIMESTAMP();
Line 44: Line 44:
-- real data
-- real data
SET @cnt_source := (SELECT COUNT(*) FROM `source_table`);
SET @cnt_source := (SELECT COUNT(*) FROM `source_table`);
SET @cnt_target := (SELECT COUNT(*) FROM `parsed_table`);
SET @cnt_target := (SELECT COUNT(*) FROM `target_table`);
SELECT IF(@cnt_source <> @cnt_target, @cnt_error := @cnt_error + 1, '');
SELECT IF(@cnt_source <> @cnt_target, @cnt_error := @cnt_error + 1, '');
SELECT IF(@cnt_source <> @cnt_target, @message := CONCAT(@message, 'some problem!', '\r'), '');
SELECT IF(@cnt_source <> @cnt_target, @message := CONCAT(@message, 'some problem!', '\r'), '');

Navigation menu