NOx is a harmful gas that causes respiratory diseases and acid rain. Commonly used photocatalysts for degrading NOx such as UV responsive TiO2 show weak photocatalytic degradation efficiency under visible light. Furthermore, the great concern is that the degradation product, nitrates (NO3-), from NOx could be washed away and increase the nitrogen deposition and eutrophication in the surrounding soil and aquatic environments, resulting in serious secondary pollution. To address these issues, this study proposes a novel solution by incorporating S-g-C3N4/MgAl-CLDH nanocomposites into a cementitious system which features high NOx degradation efficiency under visible light condition and the efficient capture and adsorption of NO3- in situ. The NOx degradation was comprehensively studied, encompassing the influencing factors and stability. The mechanism for NO3- adsorption process was expounded using the isothermal model. The results show that the amount of exposed S-g-C3N4/MgAl-CLDH and the contact area between S-g-C3N4/MgAl-CLDH and NOx are the essential reasons affecting the NOx degradation. The NOx degradation ability of photocatalytic mortar exhibits excellent stability with the NOx removal ratio decreasing by only 4.8 % and 14.5 % after ten consecutive tests and 120 min of ultrasonic washing, respectively. Furthermore, S-g-C3N4/MgAl-CLDH increases the NO3- adsorption capacity of photocatalytic mortar by about 1.5 times, and the adsorption process of NO3- follows the Freundlich isotherm. The study offers an alternate method for designing innovative nanocomposites in cement-based materials to control environmental pollution.